fix: Message Compaction System - Critical Bug Fixes #146
+333
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Message Compaction System - Critical Bug Fixes
Problem
The message compaction system had two critical bugs:
Missing method:
PlanningAgent object has no attribute 'compact_messages'- The code calledself.compact_messages()which doesn't exist; it should beself.summarize_messages()Global flag state leak: The
_delayed_compaction_requestedflag was a global variable that could leak state between sessions. Additionally, the flag was never reset when/compactwas executed manually, causing spurious delayed compaction attempts on subsequent messages.Solution
Fixed method call in
base_agent.py:1796- Changedself.compact_messages()toself.summarize_messages()Refactored global flag to instance attribute in
base_agent.py:93- Moved_delayed_compaction_requestedfrom module-level global to instance variableself._delayed_compaction_requestedto prevent state contamination between sessionsAdded flag reset in
/compactcommand insession_commands.py- Addedagent._delayed_compaction_requested = Falseto reset the flag after manual compactionAdded comprehensive test coverage - Created
tests/agents/test_base_agent_compaction_flags.pywith 9 unit tests covering flag lifecycle, idempotency, and instance isolationFiles Changed
code_puppy/agents/base_agent.py- Flag refactor + method fixcode_puppy/command_line/session_commands.py- Flag reset in/compacttests/agents/test_base_agent_compaction_flags.py- New test file (9 tests)Testing
Backwards Compatibility