fix(agent): strip MEDIA directives from compressor summarizer input (salvages #15369)#44708
Merged
Conversation
Avoid recompiling the pattern on every _serialize_for_summary call; name it beside _PATH_MENTION_RE with the #14665 rationale.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/agent/test_compressor_media_stripping.py:7: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 5687 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
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
MEDIA delivery directives are stripped from the compressor's summarizer input, so compaction summaries can no longer carry
MEDIA:<path>tags that downstream models re-emit as bogus attachment sends.Root cause (#14665):
_serialize_for_summaryredacts secrets but passedMEDIA:\S+directives through verbatim; gateway adapters parse re-emitted tags and attempt attachment delivery for stale paths.Closes #14665.
Changes
agent/context_compressor.py:MEDIA:\S+→[media attachment]in_serialize_for_summary— from fix(agent): strip MEDIA directives from compressor summarizer input (#14665) #15369 by @Tranquil-Flow_MEDIA_DIRECTIVE_RE, beside_PATH_MENTION_RE) instead of recompiling per calltests/agent/test_compressor_media_stripping.py: 4 regression tests (from the contributor PR)Note: the issue's second leg (todo snapshot injected as a user-role message) is partially mitigated by the historical-framing prefix work in #44454; tracking separately if it still reproduces.
Validation
MEDIA:/path/img.pngin compacted turns[media attachment]placeholderscripts/run_tests.shmedia/compressor/prefix suites(test_context_compressor.py currently times out in the hermetic runner on origin/main as well — pre-existing env issue, not introduced here; the same file passed against this diff in a direct run earlier: 90/94 with the 4 failures reproducing identically on clean main.)
Attribution
Salvages #15369 by @Tranquil-Flow — cherry-picked with authorship preserved; rebase-merge to keep per-commit credit.
Infographic