- Raise trigger threshold from 75% to 90% of context window
- Replace last-N-messages tail retention with user-message token budget
(20 000 tokens, newest-first, truncate rather than drop on overflow)
- Place compaction summary last in replacement history (was first)
- Upgrade summary prompt to structured handoff schema ("for another agent
instance to resume this task") matching Codex SUMMARIZATION_PROMPT
- Filter out prior <conversation-summary> messages when collecting user
texts so stale summaries are not recycled into the replacement history
- Add truncate_to_token_budget helper for mixed ASCII/CJK text
- Add with_user_message_token_budget builder on SummarizeCompactionStrategy
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>