Python: fix(orchestrations): preserve multimodal content during agent handoff - #7823
Conversation
There was a problem hiding this comment.
Pull request overview
Preserves multimodal content during orchestration handoffs, while also adding an unrelated AG-UI snapshot option.
Changes:
- Adds a handoff content allowlist.
- Tests URI preservation and tool-content removal.
- Adds configurable AG-UI snapshot suppression.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/orchestrations/agent_framework_orchestrations/_orchestrator_helpers.py |
Retains allowlisted content during handoffs. |
python/packages/orchestrations/tests/test_handoff.py |
Tests URI retention. |
python/packages/ag-ui/agent_framework_ag_ui/_agent.py |
Adds snapshot emission configuration. |
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py |
Applies snapshot suppression. |
python/packages/ag-ui/tests/ag_ui/test_run.py |
Tests snapshot suppression. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
cf7afaa to
a3a23c6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
python/packages/orchestrations/agent_framework_orchestrations/_orchestrator_helpers.py:31
- The updated return description still conflicts with the function summary and bullets above, which say the helper is text-only and drops every non-text item. Update the complete contract to describe retained multimodal content and removed tool-control payloads.
Cleaned conversation history with semantic multimodal content preserved, suitable for handoff routing
|
Please re-open when failing CI/CD checks are addressed. |
Evan Mattson (moonbox3)
left a comment
There was a problem hiding this comment.
One item for you to look at as well.
| msg_copy = Message( | ||
| role=msg.role, | ||
| contents=[" ".join(text_parts)], | ||
| contents=retained_contents, |
There was a problem hiding this comment.
What happens when an agent returns data or uri content? This keeps the assistant role, so the OpenAI clients serialize those parts as input_file or input_image, which are input-only content and make the next handoff request fail. Could we retain multimodal parts only from user messages here, while preserving text on the existing roles?
There was a problem hiding this comment.
Evan Mattson (@moonbox3) Thanks for the feedback! I've updated the handoff logic to only retain multimodal content for user messages, keeping assistant messages text-only to avoid the OpenAI input serialization issue. Reopening for review!
Motivation & Context
Multi-modal workflows (like
GroupChatandHandoffAgentExecutor) were silently dropping image and file attachments during agent handoffs. This prevented downstream Vision models from receiving the necessary context to complete their tasks. This fix ensures that multi-modal data is properly preserved across handoffs.Description & Review Guide
I updated the filtering logic in
clean_conversation_for_handoff. The previous logic aggressively dropped all non-text content. I replaced this with a safer allowlist (text,data,uri,hosted_file, etc.) that preserves multi-modal context while still successfully stripping out tool-control payloads. I updated thetest_handoff.pytests to cover this behavior, and added a regression test totest_sequential.pyto explicitly confirmSequentialBuildernatively preserves this data.Vision models will now correctly receive image context and file attachments from prior steps during sequential handoffs.
Please take a quick look at the
ALLOWED_CONTENT_TYPESset to ensure you agree with the types I allowed through. Thank you for your time and review!Related Issue
Fixes #7822
Contribution Checklist