Originally posted by wigging July 5, 2026
I'm trying to figure out how to interact with a multi-agent workflow that is served with AG-UI. My server code is shown below which is based on the example in the Agent Framework docs.
# server.py
from textwrap import dedent
import uvicorn
from agent_framework import Agent, Message, Workflow
from agent_framework_ag_ui import add_agent_framework_fastapi_endpoint
from agent_framework_ag_ui import AgentFrameworkWorkflow
from agent_framework.openai import OpenAIChatClient
from agent_framework.orchestrations import HandoffBuilder
from dotenv import load_dotenv
from fastapi import FastAPI
def create_agents() -> tuple:
"""Create agents for the workflow."""
chat_client = OpenAIChatClient(model="gpt-5.5")
triage_agent = Agent(
client=chat_client,
name="triage_agent",
instructions=dedent("""\
You are the triage agent.
Decide whether the user needs one of these specialist agents:
- math_agent: arithmetic, calculations, equations, or math explanations.
- writing_agent: rewrite, summarize, edit, or improve text.
- code_agent: Python, programming, debugging, or software development questions.
Hand off to the best agent. Do not answer the task yourself.
"""),
require_per_service_call_history_persistence=True,
)
math_agent = Agent(
client=chat_client,
name="math_agent",
instructions=(
"You solve math and calculation problems. Return the answer clearly. "
"Do not hand off unless the user asks for a different kind of help."
),
require_per_service_call_history_persistence=True,
)
writing_agent = Agent(
client=chat_client,
name="writing_agent",
instructions=(
"You rewrite, summarize, edit, and improve text. Return the improved text clearly. "
"Do not hand off unless the user asks for a different kind of help."
),
require_per_service_call_history_persistence=True,
)
code_agent = Agent(
client=chat_client,
name="code_agent",
instructions=(
"You answer Python, programming, debugging, and software development questions. "
"Do not hand off unless the user asks for a different kind of help."
),
require_per_service_call_history_persistence=True,
)
return triage_agent, math_agent, writing_agent, code_agent
def termination_condition(conversation: list[Message]) -> bool:
for msg in reversed(conversation):
if msg.role == "assistant" and (msg.text or "").strip().lower().endswith(
"case complete."
):
return True
return False
def create_workflow() -> Workflow:
"""Create a handoff workflow."""
triage_agent, math_agent, writing_agent, code_agent = create_agents()
builder = HandoffBuilder(
name="handoff",
participants=[triage_agent, math_agent, writing_agent, code_agent],
termination_condition=termination_condition,
)
builder.add_handoff(triage_agent, [math_agent, writing_agent, code_agent])
builder.with_start_agent(triage_agent)
return builder.build()
def main():
"""Run the server."""
load_dotenv()
workflow = AgentFrameworkWorkflow(
workflow_factory=lambda _thread_id: create_workflow(),
name="workflow",
description="Example of a handoff workflow.",
)
app = FastAPI(title="AG-UI Workflow Server")
add_agent_framework_fastapi_endpoint(app, workflow)
uvicorn.run(app)
if __name__ == "__main__":
main()
My client code is shown next. It connects to the AG-UI server which I'm running locally on port 8000. This client code works fine when I serve a single agent and I can send several user messages in the same session without problems. But I'm having issues when the server is for a workflow.
# client.py
import asyncio
from agent_framework import Agent
from agent_framework_ag_ui import AGUIChatClient
async def main():
"""Run the client."""
server_url = "http://127.0.0.1:8000/"
chat_client = AGUIChatClient(endpoint=server_url)
agent = Agent(
name="Client Agent",
client=chat_client,
instructions="you are a helpful assistant",
)
thread = agent.create_session()
try:
while True:
# Get user input
message = input("\nUser (:q or quit to exit): ")
if not message.strip():
print("Request cannot be empty.")
continue
if message.lower() in (":q", "quit"):
break
# Stream the agent response
print("\nAssistant: ", end="", flush=True)
async for update in agent.run(message, session=thread, stream=True):
# Print text content as it streams
if update.text:
print(f"\033[96m{update.text}\033[0m", end="", flush=True)
print("\n")
except KeyboardInterrupt:
print("\n\nExiting...")
except Exception as e:
print(f"\n\033[91mAn error occurred: {e}\033[0m")
if __name__ == "__main__":
asyncio.run(main())
This works for the initial user message (prompt) but subsequent messages fail on the server. The error given below is from the server after the second message is sent.
agent_framework.exceptions.ChatClientException:
("<class 'agent_framework_openai._chat_client.OpenAIChatClient'> service failed to complete the prompt:
Error code: 400 - {'error': {'message': 'No tool output found for function call 0c9a1ef3-ba95-4ae6-9d11-7fbab624bdd9.',
'type': 'invalid_request_error', 'param': 'input', 'code': None}}",
BadRequestError("Error code: 400 - {'error': {'message': 'No tool output found for function call 0c9a1ef3-ba95-4ae6-9d11-7fbab624bdd9.', 'type': 'invalid_request_error', 'param': 'input', 'code': None}}"))
I can't find much information in the Agent Framework docs regarding the client side code for multi-agent workflows. How am I supposed to interact with an AG-UI workflow server? Does the client code need to use an ID or something else to connect with the workflow? This was fairly straightforward with a single agent but seems to be more involved with workflows.
Discussed in #6914
Originally posted by wigging July 5, 2026
I'm trying to figure out how to interact with a multi-agent workflow that is served with AG-UI. My server code is shown below which is based on the example in the Agent Framework docs.
My client code is shown next. It connects to the AG-UI server which I'm running locally on port 8000. This client code works fine when I serve a single agent and I can send several user messages in the same session without problems. But I'm having issues when the server is for a workflow.
This works for the initial user message (prompt) but subsequent messages fail on the server. The error given below is from the server after the second message is sent.
I can't find much information in the Agent Framework docs regarding the client side code for multi-agent workflows. How am I supposed to interact with an AG-UI workflow server? Does the client code need to use an ID or something else to connect with the workflow? This was fairly straightforward with a single agent but seems to be more involved with workflows.