microsoft / microsoft/agent-framework
Python: [Bug]: AG-UI skips assistant text when response_format is a JSON Schema mapping
@eavanvalkenburg is already working on this.
Since Sep 14, 2026.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
### Description
`Agent` documents two `response_format` values: a Pydantic model, or a JSON Schema mapping (`dict`). AG-UI only completes the first path.
When `agent.default_options["response_format"]` is set, `_run_agent` sets `skip_text = True` and does not stream `TEXT_MESSAGE_*` events. After the run it only re-emits text if `response_format` is a Pydantic `BaseModel` (and then only the model's `message` field). A mapping schema hits:
```
Skipping structured output parsing: response_format is not a Pydantic model type.
```
The model still produces tokens, but the AG-UI stream / thread snapshot has no assistant message.
Expected: a JSON Schema / `{"type": "json_object"}` `response_format` should still surface as assistant text (stream the JSON, or emit `response.text` / parsed JSON after the run). Pydantic + `StateSnapshot` behavior can stay as-is.
Steps:
1. Create an agent with `default_options={"response_format": {"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}}`.
2. Wrap it in `AgentFrameworkAgent` and run a user message through AG-UI.
3. Observe usage tokens but no `TEXT_MESSAGE_CONTENT` / assistant snapshot message.
### Code Sample
```python
from agent_framework import Agent
from agent_framework.ag_ui import AgentFrameworkAgent
schema = {
"type": "object",
"properties": {"name": {"type": "string"}, "age": {"type": "integer"}},
"required": ["name", "age"],
}
agent = Agent(
name="extractor",
instructions="Extract person info as JSON.",
client=client, # any Completions-compatible client
default_options={"response_format": schema},
)
wrapper = AgentFrameworkAgent(agent=agent)
# Run via AG-UI: TEXT_MESSAGE_* never emitted for the JSON body.
```
Relevant code in `python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py`:
- `skip_text = response_format is not None` (any format, including mappings)
- later: `if not (isinstance(response_format, type) and issubclass(response_format, BaseModel)): logger.warning("Skipping structured output parsing...")`
### Error Messages / Stack Traces
No exception. Warning only:
```
Skipping structured output parsing: response_format is not a Pydantic model type.
```
Run completes with `outputTokens > 0` and a user message in the thread snapshot, but no assistant message.
### Package Versions
agent-framework-ag-ui: 1.3.0
agent-framework-core: 1.18.0
### Python Version
Python 3.13.11
### Additional Context
Docs: https://learn.microsoft.com/en-us/agent-framework/agents/structured-outputs?pivots=programming-language-python
Suggested fix: when `response_format` is a mapping, do not set `skip_text`, or after the run emit `AgentResponse.from_updates(...).text` (or the parsed JSON) as `TEXT_MESSAGE_*`. Keep the Pydantic shared-state path unchanged.
Happy to send a PR if that direction looks right.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.