fix(agent): preserve multimodal user content through crash-resilience persist - #47907
Merged
Conversation
Avoid applying text-only persist_user_message overrides to multimodal current-turn user messages. Early crash-resilience persistence mutates the same messages list later used for the API call, so clobbering list content drops ACP image blocks before model dispatch.\n\nAdd regression coverage for both text override behavior and multimodal preservation.\n\nCloses #44242
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
✅ Fixed issues (2):
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
run_agent.py:2933: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
Unchanged: 5790 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced Jun 17, 2026
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
Images attached to a user turn now survive to the model call instead of being silently dropped before the API request is built.
Root cause:
_apply_persist_user_message_overrideunconditionally overwrote the current-turn user messagecontentwith the text-only persist string.build_turn_contextruns a crash-resilience persist of the inbound turn before the first API call, on the samemessageslist the request is later built from — so a multimodal[text, image_url]user turn got clobbered to plain text, and the image was gone end-to-end. This hits every provider regardless of vision support: ACPsession/promptimage blocks (#44242) and Telegram native-vision image attachments alike.Changes
run_agent.py: skip the content override when the user message content is a multimodal list; the paired timestamp override still applies (it's metadata, not content).tests/run_agent/test_run_agent.py: regression tests for the multimodal-preserved and text-rewritten paths.scripts/release.py: AUTHOR_MAP entry for the salvaged contributor.Validation
content→ plain string, image droppedcontentlist preserved, image survives, timestamp writtenTargeted suite:
tests/run_agent/test_run_agent.py -k "persist_user_message or persist_session"→ 5 passed. E2E against the real method confirms all three cases.Credit
Salvaged from #44249 by @Rivuza (authorship preserved via rebase-merge). #44247 by @liuhao1024 submitted the same one-line fix first — both contributors credited. Adapted the guard so it doesn't regress the timestamp-metadata write that landed after both PRs were filed. Closes #44242.
Infographic