classifier = Agent(
name="classifier",
model="openai/gpt-4.1-mini",
system_prompt="Classify the message as 'technical' or 'billing'. Respond with one word only."
)
technical_agent = Agent(
name="technical_agent",
model="openai/gpt-4.1",
system_prompt="You are a technical support specialist."
)
billing_agent = Agent(
name="billing_agent",
model="openai/gpt-4.1-mini",
system_prompt="You are a billing support specialist."
)
workflow = (
Workflow(name="support_router")
.step(classifier)
.step(technical_agent,
when=lambda: "technical" in get_run_context().step_span("classifier").output.collect_text().lower())
.step(billing_agent,
when=lambda: "billing" in get_run_context().step_span("classifier").output.collect_text().lower())
)
result = await workflow(prompt="I can't access my account").collect()