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:
- Create an agent with
default_options={"response_format": {"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}}.
- Wrap it in
AgentFrameworkAgent and run a user message through AG-UI.
- Observe usage tokens but no
TEXT_MESSAGE_CONTENT / assistant snapshot message.
Code Sample
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.
Description
Agentdocuments tworesponse_formatvalues: 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_agentsetsskip_text = Trueand does not streamTEXT_MESSAGE_*events. After the run it only re-emits text ifresponse_formatis a PydanticBaseModel(and then only the model'smessagefield). A mapping schema hits:The model still produces tokens, but the AG-UI stream / thread snapshot has no assistant message.
Expected: a JSON Schema /
{"type": "json_object"}response_formatshould still surface as assistant text (stream the JSON, or emitresponse.text/ parsed JSON after the run). Pydantic +StateSnapshotbehavior can stay as-is.Steps:
default_options={"response_format": {"type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"]}}.AgentFrameworkAgentand run a user message through AG-UI.TEXT_MESSAGE_CONTENT/ assistant snapshot message.Code Sample
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)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:
Run completes with
outputTokens > 0and 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_formatis a mapping, do not setskip_text, or after the run emitAgentResponse.from_updates(...).text(or the parsed JSON) asTEXT_MESSAGE_*. Keep the Pydantic shared-state path unchanged.Happy to send a PR if that direction looks right.