Persist compression boundary summary for reload UI - #2004
Conversation
SummaryReading Code referenceThe persistence shape is symmetric across both paths: # api/models.py:411-413 — METADATA_FIELDS now includes the new field
'compression_anchor_visible_idx', 'compression_anchor_message_key',
'compression_anchor_summary',And # api/streaming.py:3082-3093
if _compressed:
visible_after = _visible_messages_for_compression_anchor(s.messages)
s.compression_anchor_visible_idx = (
max(0, len(visible_after) - 1) if visible_after else None
)
s.compression_anchor_message_key = (
_compression_anchor_message_key(visible_after[-1]) if visible_after else None
)
s.compression_anchor_summary = _compact_summary_text(
_compression_summary_from_messages(s.messages)
or _compression_summary_from_messages(s.context_messages)
)The render path correctly falls back to the persisted summary when the raw context-compaction message is no longer in // static/ui.js:4779-4784
const referenceText=referenceMessage
? msgContent(referenceMessage)||String(referenceMessage.content||'')
: sessionCompressionSummary;
const referenceNode=(!compressionState && !!referenceText && (sessionCompressionAnchor!==null || sessionCompressionAnchorKey || sessionCompressionSummary))
? ...
: null;Diagnosis / recommendationThe change is well-scoped and the contract holds across the three layers (Session save/load, route response, render path). A few notes:
Test plan
What's missing: a streaming-path test that drives Cross-repo noteThis is webui-side display-state only. The agent's compressor ( LGTM. Closes #1833 cleanly given the manual-path pin. |
a42adbe
…oundary summary for reload UI by @franksong2702
…oundary summary for reload UI by @franksong2702
…oundary summary for reload UI by @franksong2702
Summary
This PR resolves #1833.
/session/compress:compression_anchor_summarycompression_anchor_visible_idxcompression_anchor_message_keyrun_conversationpath), so the boundary marker survives session reloads.session.compression_anchor_summarywhen the raw context-compaction message is not present inS.messages.Testing
/.venv_test/bin/python -m pytest -q tests/test_sprint46.py tests/test_auto_compression_card.py/.venv_test/bin/python -m py_compile api/routes.py api/streaming.py api/models.pynode --check static/ui.js