Skip to content

Python: Fix structured value parsing for split text chunks#6990

Open
t-anjan wants to merge 3 commits into
microsoft:mainfrom
t-anjan:fix/structured-output-value-chunks
Open

Python: Fix structured value parsing for split text chunks#6990
t-anjan wants to merge 3 commits into
microsoft:mainfrom
t-anjan:fix/structured-output-value-chunks

Conversation

@t-anjan

@t-anjan t-anjan commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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:

  • cd python && uv run pytest packages/core/tests/core/test_types.py
  • cd python && uv run ruff check packages/core/agent_framework/_types.py packages/core/tests/core/test_types.py
  • git diff --check

Copilot AI review requested due to automatic review settings July 8, 2026 09:11
@giles17 giles17 added the python Usage: [Issues, PRs], Target: Python label Jul 8, 2026
@github-actions github-actions Bot changed the title Fix structured value parsing for split text chunks Python: Fix structured value parsing for split text chunks Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.value and AgentResponse.value to parse structured output from the structured-only text path instead of self.text.
  • Added regression tests covering split JSON across text chunks while preserving Message.text spacing 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.

Comment thread python/packages/core/agent_framework/_types.py Outdated
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _types.py12229792%61, 70–71, 125, 130, 149, 151, 155, 159, 161, 163, 165, 183, 187, 213, 235, 240, 245, 249, 279, 703–704, 863–864, 1299, 1371, 1406, 1426, 1436, 1488, 1620–1622, 1907–1912, 1937, 1992, 1997, 2007, 2015, 2022–2026, 2044, 2117, 2130, 2135, 2252, 2275, 2531, 2555, 2654, 2830–2831, 2933, 3162, 3215, 3234, 3273, 3284, 3286–3290, 3292, 3295–3303, 3313, 3402, 3539, 3544, 3549, 3554, 3558, 3644–3646, 3675, 3763–3767
TOTAL44497534687% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
8818 33 💤 0 ❌ 0 🔥 2m 7s ⏱️

@moonbox3 moonbox3 requested a review from eavanvalkenburg July 8, 2026 09:44
t-anjan and others added 3 commits July 8, 2026 15:17
@t-anjan t-anjan force-pushed the fix/structured-output-value-chunks branch from 98dc0f1 to a5f64d6 Compare July 8, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants