fix(agent): metadata flag on compression summary messages, wire-safe key (salvages #38434)#45281
Conversation
…#38389) Summary messages (standalone insertion and merge-into-tail) now carry a metadata flag so frontends (CLI, Desktop, gateway, TUI) can distinguish them from real assistant/user messages without content-prefix heuristics. Re-applied from PR #38434 onto current main (conflicted with the _SUMMARY_END_MARKER hoist). Key renamed from the PR's 'is_compressed_summary' to '_compressed_summary': the wire sanitizers strip underscore-prefixed message keys, so the flag stays in-process and can never reach strict gateways (Fireworks/Mistral/Kimi reject unknown keys with 'Extra inputs are not permitted').
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/agent/test_compressed_summary_metadata.py:17: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 5705 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
|
Verification: Code Review — Clean ✅ Reviewed the compressed-summary metadata flag. Key checks:
No issues found. Clean, well-tested behavioral addition with proper wire-safety guarantees. |
Summary
Context compression summary messages now carry an in-process metadata flag (
_compressed_summary: True) so frontends (CLI, Desktop, gateway, TUI) can identify them without content-prefix heuristics (#38389).Closes #38389. (Dupes #38391, #38392 close with it.)
Changes
agent/context_compressor.py: flag set on the standalone summary message AND the merge-into-tail message;_has_compressed_summary_metadata()helper for consumers — from fix(agent): add metadata flag to context compression summary messages #38389 #38434 by @kyssta-exeis_compressed_summary(bare key) — that would ride messages onto the wire, and strict gateways (Fireworks, Mistral, Moonshot/Kimi, opencode-go) 400 on unknown message keys ("Extra inputs are not permitted"). Renamed to underscore-prefixed_compressed_summary, which the existing wire sanitizers (ChatCompletionsTransport.convert_messages+ the summary-path mirror inchat_completion_helpers.py) already striptests/agent/test_compressed_summary_metadata.py: flag set in-process, underscore invariant, transport strips it without destroying the in-process flagValidation
compress()+ realChatCompletionsTransport)Attribution
Salvages #38434 by @kyssta-exe — commit re-applied onto current main (conflicted with the
_SUMMARY_END_MARKERhoist) with authorship preserved; rebase-merge to keep per-commit credit. The key rename is our follow-up commit.Infographic