Python: Fix structured value parsing for split text chunks#6990
Open
t-anjan wants to merge 3 commits into
Open
Python: Fix structured value parsing for split text chunks#6990t-anjan wants to merge 3 commits into
t-anjan wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes structured-output parsing for ChatResponse.value and AgentResponse.value by avoiding the synthetic spaces introduced by Message.text when a message contains multiple text Content chunks (which can corrupt split JSON). The public Message.text/Response.text behavior remains unchanged for display.
Changes:
- Added structured-output-only text assembly helpers that concatenate text chunks without inserting spaces.
- Updated
ChatResponse.valueandAgentResponse.valueto parse structured output from the structured-only text path instead ofself.text. - Added regression tests covering split JSON across text chunks while preserving
Message.textspacing behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_types.py | Adds structured-only text helpers and switches structured parsing to use them (avoids Message.text synthetic spacing). |
| python/packages/core/tests/core/test_types.py | Adds tests ensuring split structured JSON parses correctly without changing Message.text/response.text. |
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
moonbox3
approved these changes
Jul 8, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
98dc0f1 to
a5f64d6
Compare
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.
Structured response parsing currently uses the public text property, which inserts spaces between TextContent chunks inside a Message. That can corrupt split JSON structured outputs while leaving normal display text behavior correct.
This change keeps Message.text unchanged and uses a structured-output-only text path that concatenates text chunks without synthetic spaces before parsing ChatResponse.value and AgentResponse.value.
Tests: