Context overflow when compacting history#134
Conversation
EntelligenceAI PR SummaryRefactors
Confidence Score: 5/5 - Safe to MergeSafe to merge — this PR refactors Key Findings:
Files requiring special attention
|
There was a problem hiding this comment.
Refactors ChatSession in anton/core/session.py to centralize and improve context overflow recovery logic.
- Introduced
plan_with_recovery: non-streaming helper with three-tier recovery (normal → summarize+compact → hard-truncate) - Introduced
plan_stream_with_recovery: streaming analogue that yieldsStreamContextCompactedevents on compaction - Added
hard_truncate_history: last-resort fallback that preserves only the tail of history while enforcing API message-ordering rules - Promoted
_compacted_this_turnfrom a local variable to an instance variable, reset at the start of each turn, preventing double-summarization across both paths - Replaced all direct
self._llm.planandself._llm.plan_streamcall sites inturnand_stream_and_handle_toolswith the new helpers - Refactored task-completion verifier to use a
messages_factorycallable, ensuring post-compaction history is reflected on retry
|
@Entelligence review |
|
Starting fresh pr review. This may take a few minutes |
|
New pr review completed! Check the pr for comments. |
Fixes #106
Add three-tier ContextOverflowError recovery to session helpers