Skip to content

ag_ui module not working with structured output_type #3011

@lukekh

Description

@lukekh

Initial Checks

Description

Function calling seems to be working in general, however when there is a structured output_type the AG-UI client doesn't seem to return the corresponding tool_call_response while using the handle_ag_ui_request function.

Using logfire I could see that the tool_call_response was generated in the response, but when the request is being built the tool_call_response message part is missing.

Example Code

from enum import Enum
from pydantic_ai import Agent
from pydantic_ai.ag_ui import handle_ag_ui_request
from starlette.requests import Request

class output_type(Enum):
    A = "a"
    B = "b"

agent = Agent(
    output_type=output_type
)

async def agent_endpoint(request: Request):
    return await handle_ag_ui_request(agent, request)

Python, Pydantic AI & LLM client version

python 3.11, pydantic-ai-slim==1.0.10, LLM client is OpenAI (Azure) with openai==1.109.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions