-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Description
When exporting a GroupChat workflow for DevUI discovery, the DevUI server fails with a PydanticSerializationError because GroupChat events contain AgentResponse objects which Pydantic's model_dump_json() cannot serialize.
Steps to Reproduce
- Create a file with a GroupChat workflow exported for DevUI discovery:
from agent_framework import ChatAgent, GroupChatBuilder
from agent_framework.azure import AzureOpenAIChatClient
def get_azure_chat_client():
return AzureOpenAIChatClient(
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
azure_deployment=os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"),
api_version="2025-01-01-preview",
)
chat_client = get_azure_chat_client()
agent1 = ChatAgent(name="Agent1", instructions="...", chat_client=chat_client)
agent2 = ChatAgent(name="Agent2", instructions="...", chat_client=chat_client)
def create_workflow():
return (
GroupChatBuilder()
.participants([agent1, agent2])
.build()
)
# Export for DevUI discovery
workflow = create_workflow()-
Run DevUI:
devui . -
Open the DevUI in browser and try to use the workflow
Expected Behavior
GroupChat workflows should work in DevUI just like single ChatAgents.
Actual Behavior
DevUI returns HTTP 422 Unprocessable Content:
INFO: 127.0.0.1:56972 - "GET /v1/entities/example/info?type=workflow HTTP/1.1" 422 Unprocessable Content
The underlying error is:
PydanticSerializationError: Unable to serialize unknown type: <class 'agent_framework._types.AgentResponse'>
Root Cause Analysis
Looking at the codebase:
AgentResponseextendsSerializationMixinand hasto_dict()/to_json()methods- However, when Pydantic tries to serialize events from GroupChat using
model_dump_json(), it doesn't know how to handleAgentResponseobjects embedded in the events - The
_mapper.pyhas_serialize_content_recursive()function, but it seems this isn't being applied in the DevUI serialization path
Workaround
Currently, the only workaround is to export a single ChatAgent instead of a GroupChat workflow for DevUI compatibility:
# Instead of exporting GroupChat workflow
agent = ChatAgent(name="MyAgent", instructions="...", chat_client=chat_client)Environment
- agent-framework version: latest
- agent-framework-devui version: latest
- Python version: 3.13
- OS: macOS
Suggested Fix
Consider one of these approaches:
- Add custom Pydantic serializers for
AgentResponseand related types - Use the existing
_serialize_content_recursive()logic in the DevUI serialization path - Register
AgentResponseas a known Pydantic type with proper serialization
Related Code
agent_framework/_types.py-AgentResponseclass withSerializationMixinagent_framework/_mapper.py-_serialize_content_recursive()functiontest_execution.py-test_full_pipeline_agent_events_are_json_serializabletest (shows this is a known concern)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status