Python: fix(ag ui): allow text events when response_format is a json schema dictionary by ManoharPaturi · Pull Request #8604 · microsoft/agent-framework · GitHub
Skip to content

Python: fix(ag ui): allow text events when response_format is a json schema dictionary - #8604

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/ag-ui-json-schema-text
Sep 22, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/ag-ui-json-schema-text

Conversation

@ManoharPaturi

@ManoharPaturi Manohar Paturi (ManoharPaturi) commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

When response_format is configured as a raw JSON Schema dictionary rather than a Pydantic model class, skip_text was previously set to True under the assumption that all structured formats are handled as Pydantic models.

However, non-Pydantic formats do not map into model fields or state snapshots. As a result, the assistant's JSON response text was being dropped silently from the AG-UI event stream, breaking clients expecting text content. This change ensures skip_text is only enabled when response_format is a Pydantic BaseModel type. When response_format is a JSON schema mapping or other non-model structure, text content events continue to emit normally.

Description & Review Guide

  • What are the major changes?
    In python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py, check isinstance(response_format, type) and issubclass(response_format, BaseModel) before setting skip_text = True.
    Demoted the warning log to debug when response_format is not a Pydantic model, since JSON schema dictionaries are valid input configurations.
    Added unit test test_structured_output_with_json_schema_mapping_emits_text in python/packages/ag-ui/tests/ag_ui/test_structured_output.py verifying that text events are emitted when response_format is a schema dictionary.

  • What is the impact of these changes?
    Fixes silent dropping of assistant response text when using dictionary-based JSON schemas in AG-UI runs, allowing AG-UI consumers to receive the structured JSON output text.

  • What do you want reviewers to focus on?
    The is_pydantic_response_format determination and the new test case covering JSON schema dictionary formats.

Related Issue

Closes #8361

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 21, 2026
@github-actions github-actions Bot changed the title fix(ag ui): allow text events when response_format is a json schema dictionary Python: fix(ag ui): allow text events when response_format is a json schema dictionary Sep 21, 2026
…ictionary

When response_format is configured as a json schema dict rather than a Pydantic BaseModel, skip_text was previously set to True, which suppressed text content events. This change ensures skip_text is only enabled for Pydantic models whose fields map directly to state or message fields. Non-model formats keep emitting text content events as expected.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@eavanvalkenburg

Copy link
Copy Markdown
Member

@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Merged via the queue into microsoft:main with commit 02bd1ba Sep 22, 2026
43 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 6d2ae7ec Deployed Sep 22, 2026 by ManoharPaturi via add_label #23530
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.

Python: [Bug]: AG-UI skips assistant text when response_format is a JSON Schema mapping

3 participants