Restores the message tool suppression feature that was accidentally removed during refactoring. This prevents users from receiving duplicate messages when the agent uses the message tool to reply to them.
Problem
When the agent uses the message tool to send a reply to the same channel/chat_id as the incoming message, users receive TWO messages:
The message from the message tool
The automatic final reply
Solution
Add _sent_in_turn tracking to MessageTool
Set flag when message tool sends to same target as incoming message
Suppress automatic final reply when flag is set
Changes
nanobot/agent/tools/message.py: Add _sent_in_turn field, start_turn() method, and tracking logic
nanobot/agent/loop.py: Call start_turn() at beginning, check flag before sending final reply
Testing
All 5 tests in test_message_tool_suppress.py now pass:
✅ Suppress when sent to same target
✅ Don't suppress when sent to different target
✅ Don't suppress when message tool not used
✅ Turn tracking works correctly
✅ start_turn() resets flag
History
This feature was originally implemented in commits fafd8d4 (Feb 26) and 29e6709 (Feb 27), but was accidentally removed during subsequent refactoring.
🤖 Generated with Claude Code
## Summary
Restores the message tool suppression feature that was accidentally removed during refactoring. This prevents users from receiving duplicate messages when the agent uses the message tool to reply to them.
## Problem
When the agent uses the `message` tool to send a reply to the same channel/chat_id as the incoming message, users receive TWO messages:
1. The message from the message tool
2. The automatic final reply
## Solution
- Add `_sent_in_turn` tracking to MessageTool
- Set flag when message tool sends to same target as incoming message
- Suppress automatic final reply when flag is set
## Changes
- `nanobot/agent/tools/message.py`: Add `_sent_in_turn` field, `start_turn()` method, and tracking logic
- `nanobot/agent/loop.py`: Call `start_turn()` at beginning, check flag before sending final reply
## Testing
All 5 tests in `test_message_tool_suppress.py` now pass:
- ✅ Suppress when sent to same target
- ✅ Don't suppress when sent to different target
- ✅ Don't suppress when message tool not used
- ✅ Turn tracking works correctly
- ✅ start_turn() resets flag
## History
This feature was originally implemented in commits fafd8d4 (Feb 26) and 29e6709 (Feb 27), but was accidentally removed during subsequent refactoring.
🤖 Generated with Claude Code
The `last_consolidated` marker was designed for incremental consolidation
assuming append-only messages. However, deferred trim removes messages from
the session, which broke the incremental assumption and caused consolidation
to fail silently (early exit when end_idx <= stale last_consolidated).
After trim, the session only contains NEW unconsolidated messages, making
the marker unnecessary. Consolidation now always starts from index 0,
processing all messages in the session (which are by definition not yet
consolidated due to trim).
Fixes the bug where extraction completely stopped working after trim
(zero facts extracted despite multiple consolidation attempts).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The test_consolidate_offset.py file contained ~100 tests for the
last_consolidated field which no longer exists. Since the field and its
incremental consolidation behavior have been removed, these tests are
obsolete.
Also removed redundant empty check in memory.py consolidation (if
len <= keep_count, then slice will be empty).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When the agent uses the message tool to reply to the same channel/chat_id
as the incoming message, the final automatic reply is now suppressed to
prevent duplicate messages to the user.
Changes:
- MessageTool: add _sent_in_turn flag and start_turn() method
- MessageTool.execute(): set flag when sending to same target as context
- AgentLoop._process_message(): call start_turn() at beginning
- AgentLoop._process_message(): return None if message tool already sent
This restores functionality that was accidentally removed during refactoring
(originally implemented in commits fafd8d4, 29e6709).
Fixes 3 failing tests in test_message_tool_suppress.py
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Restores the message tool suppression feature that was accidentally removed during refactoring. This prevents users from receiving duplicate messages when the agent uses the message tool to reply to them.
Problem
When the agent uses the
messagetool to send a reply to the same channel/chat_id as the incoming message, users receive TWO messages:Solution
_sent_in_turntracking to MessageToolChanges
nanobot/agent/tools/message.py: Add_sent_in_turnfield,start_turn()method, and tracking logicnanobot/agent/loop.py: Callstart_turn()at beginning, check flag before sending final replyTesting
All 5 tests in
test_message_tool_suppress.pynow pass:History
This feature was originally implemented in commits
fafd8d4(Feb 26) and29e6709(Feb 27), but was accidentally removed during subsequent refactoring.🤖 Generated with Claude Code