fix(agent): don't clobber multimodal user content with persist_user_message override#44248
Closed
AIalliAI wants to merge 1 commit into
Closed
fix(agent): don't clobber multimodal user content with persist_user_message override#44248AIalliAI wants to merge 1 commit into
AIalliAI wants to merge 1 commit into
Conversation
The turn-start crash-resilience persist in build_turn_context calls _apply_persist_user_message_override on the same messages list the API request is later built from. When the ACP adapter sends a multimodal prompt (text + image parts) it passes a text-only persist_user_message, so the override replaced the content-part list with a plain string before the first provider call — every image content block was dropped end-to-end, regardless of model vision support. Skip the override when the live content is a content-part list. The synthetic-prefix cleanup the override exists for only applies to text turns (voice prefix, ACP steering), and image redaction for the session DB already happens in _flush_messages_to_session_db. Fixes NousResearch#44242 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
13 tasks
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
Image content blocks sent through the ACP adapter never reached the model:
build_turn_contextruns a crash-resilience persist of the inbound user turn before the first API call, and_persist_session→_apply_persist_user_message_overridemutates the samemessageslist the request is later built from. The ACP adapter passes a text-onlypersist_user_messagefor multimodal prompts (acp_adapter/server.py), so the[{type:"text"}, {type:"image_url"}]content list was replaced with a plain string before any provider call — the image was dropped end-to-end, on every provider, regardless of vision support.Fix
_apply_persist_user_message_overridenow leaves content-part lists untouched. The synthetic-prefix cleanup the override exists for (voice prefix incli.py, ACP steering text) only ever applies to string-content turns, and image redaction for the session DB already happens downstream in_flush_messages_to_session_db(images →[screenshot]placeholder), so DB bloat is not a concern.Verification
main: ACP_content_blocks_to_openai_user_contentproduces the multimodal list →turn_context.pyearly_persist_session(crash-resilience persist) → override clobbersmsg["content"]before the request is assembled.image_urlpart through_persist_session, while the DB write still gets the redacted text form.TestPersistUserMessageOverridetext-turn test unchanged and passing — voice-prefix/steering cleanup behavior is preserved.tests/run_agent/+tests/agent/test_turn_context.py: 1627 passed, 2 failed — the twotest_provider_parity.py::TestAuxiliaryClientProviderPriorityfailures are pre-existing test-ordering pollution (they fail identically on pristineorigin/mainin a full-suite run and pass in isolation both with and without this change).Fixes #44242
🤖 Generated with Claude Code