ENG-664: persist + replay anton's history summary instead of resending full history - #192
Draft
ea-rus wants to merge 9 commits into
Draft
ENG-664: persist + replay anton's history summary instead of resending full history#192ea-rus wants to merge 9 commits into
ea-rus wants to merge 9 commits into
Conversation
ea-rus
changed the base branch from
jorge/eng-648-utility-model-settings
to
staging
July 27, 2026 14:15
ea-rus
changed the base branch from
staging
to
jorge/eng-648-utility-model-settings
July 27, 2026 14:17
ea-rus
force-pushed
the
feat/eng-664-conversations-resend-the-full-history
branch
from
July 28, 2026 10:24
27562f7 to
acaa001
Compare
|
All contributors have signed the CLA ✍️ ✅ |
ea-rus
changed the base branch from
jorge/eng-648-utility-model-settings
to
staging
July 28, 2026 10:24
No PR environment for this pull requestAdd the Updated on every push to this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Every turn, cowork rebuilt
initial_historyfrom all of a conversation's messages. Anton already compacts old turns into a summary once context pressure crosses threshold, but that summary lived only in the throwaway per-turnChatSession— cowork saved just the assistant's text, so the next turn rebuilt from raw rows and the summary was gone. Input kept growing every turn until it hit the context window, and once a conversation was long enough, every turn paid for a fresh summarization call that was immediately discarded.Conversationgainshistory_summary/history_summary_cutoff_id(migrationb3d7f1a9c5e2, no FK on the cutoff id — a stale/missing id falls back to full history rather than blocking message deletion).ConversationService.update_history_compactionpersists the summary + cutoff. History replay reuses the existingget_ordered_messages— a stable order is what makes the cutoff meaningful (the bareconversation.messagesrelationship has none).AntonHarness._seed_historybuildsinitial_historyas[summary] + [messages after cutoff]when the saved compaction is still valid, else full history (automatic fallback when the summary/cutoff looks stale). Inserts the same assistant separator anton's own_summarize_historyuses when the tail would otherwise start with auser-role message (avoids two consecutiveusermessages, which most providers reject).AntonHarness._persist_history_compactionreadssession.last_compactionafter a turn and saves it, in its own try/except instream_response'sfinallyso a persistence failure never masks the turn's real outcome. Readssession.last_compactionviagetattr(..., None)— an anton build predating this property no-ops here instead of raising; cowork-server and anton deploy independently.history_compaction_enabledsetting (defaultTrue, mirrorsmemory_enabled) — off reverts to full-history-every-turn and skips persistence; deleting a conversation's saved summary has the same effect for just that one conversation.Test plan
tests/test_history_compaction.py:_seed_history(full history / valid cutoff / stale cutoff fallback / tail-starts-with-user separator),_persist_history_compaction(no-op cases, first compaction, offset math with the separator, old-anton version-skew no-op), settings flag default/override.tests/test_history_compaction_plateau.py: a 30-turn simulation against the realChatSession+ConversationService+AntonHarnesscode (only the LLM calls are mocked) — chars/turn levels off (~800–950) instead of growing unboundedly (disabled control run reaches 4265 by turn 30); an early-turn fact stays recoverable via the summary after compaction. Guarded byskipif(not hasattr(ChatSession, "last_compaction"))so it skips cleanly until the anton pin carries fix(settings): reduce settings desync — single source of truth + atomic writes #249.test_channel_context.py,test_trace_tags_forwarding.py,test_anton_turn_capture.py) whose_build_chat_sessionmocks returned the old 2-tuple.671 passed, 1 skipped. (Twotest_build_llm_client.pyfailures appear only when running against a local anton source checkout — a provider-key-resolution discrepancy unrelated to this change; both pass under the pinned anton used in CI.)🤖 Generated with Claude Code
Dependent on mindsdb/anton#249
Fixes https://linear.app/mindsdb/issue/ENG-664/conversations-resend-the-full-history-every-turn-and-throw-away-the