Python: fix(mcp): do not duplicate structuredContent when content present - #8274
Open
LI (ktz03) wants to merge 2 commits into
Open
Python: fix(mcp): do not duplicate structuredContent when content present#8274LI (ktz03) wants to merge 2 commits into
LI (ktz03) wants to merge 2 commits into
Conversation
Fixes microsoft#7866. Prefer content blocks for model-visible tool results; structuredContent remains on the Host payload. Serialize structuredContent only when content is empty.
Author
|
Fork CI for this PR may need a maintainer to Approve workflows before Python tests run (same as other community PRs). Happy to address review feedback once checks appear. |
LI (ktz03)
had a problem deploying
to
github-app-auth
September 10, 2026 23:27 — with
GitHub Actions
Error
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Existing test expectations still require the old duplicate-output behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes duplicate MCP tool output when both content and structuredContent are present.
Changes:
- Use
structuredContentas model-visible content only when regular content is empty. - Preserve the complete structured payload for host transports.
- Update parser regression coverage.
File summaries
| File | Summary |
|---|---|
python/packages/core/agent_framework/_mcp.py |
Prevents duplicate structured content. Moderate finding (3 votes): remaining test expectations must be updated. |
python/packages/core/tests/core/test_mcp.py |
Updates structured-content parsing expectations; several existing expectations still require the old duplicate behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
Address Copilot review on microsoft#8274: update suites that still expected the old duplicated model-visible content shape.
Author
|
Follow-up for Copilot review: aligned the three suites that still expected duplicated |
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.
Description
Fixes #7866. MCP
CallToolResultoften returns bothcontentandstructuredContent._parse_tool_result_from_mcppreviously appended a JSON dump ofstructuredContenteven whencontentalready had items, so the model saw duplicated tool output.Change: only serialize
structuredContentinto model-visibleContentwhencontentproduced no items. Host transports still retain completestructuredContenton the existing Host payload marker.Validation
test_parse_tool_result_from_mcp_structured_content_with_texttest_parse_tool_result_from_mcp_structured_content_onlystill covers the empty-content fallback