Fast Agent provides powerful workflow patterns to orchestrate multiple agents for complex tasks. Workflows enable you to chain agents, run them in parallel, route requests intelligently, and implement advanced patterns like evaluator-optimizer loops.
@fast.agent( name="url_fetcher", instruction="Fetch and summarize content from URLs", servers=["fetch"])@fast.agent( name="social_media", instruction="Write 280 character social media posts. No hashtags.")@fast.chain( name="post_writer", sequence=["url_fetcher", "social_media"])async def main(): async with fast.run() as agent: await agent.post_writer("https://example.com")
@fast.chain( name="chain_name", sequence=["agent1", "agent2", "agent3"], instruction="Description for other workflows", cumulative=False, # Pass only last output vs all outputs continue_with_final=True # Open chat after execution)
@fast.agent("translate_fr", "Translate text to French")@fast.agent("translate_de", "Translate text to German")@fast.agent("translate_es", "Translate text to Spanish")@fast.parallel( name="translate_all", fan_out=["translate_fr", "translate_de", "translate_es"])async def main(): async with fast.run() as agent: # Returns combined translations result = await agent.translate_all("Hello, world!")
Routers use an LLM to analyze requests and route them to the most appropriate agent.
@fast.agent("math_expert", "Solve mathematical problems", servers=["calculator"])@fast.agent("code_expert", "Write and debug code", servers=["python"])@fast.agent("writer", "Creative writing and editing")@fast.router( name="smart_router", agents=["math_expert", "code_expert", "writer"], model="o3-mini.high" # Use capable model for routing)async def main(): async with fast.run() as agent: # Automatically routes to math_expert await agent.smart_router("What is 15% of 240?") # Automatically routes to code_expert await agent.smart_router("Write a Python function to sort a list")
Orchestrators generate execution plans and coordinate multiple agents to accomplish complex tasks.
@fast.agent("researcher", "Research topics online", servers=["fetch"])@fast.agent("analyzer", "Analyze and synthesize information")@fast.agent("writer", "Write clear documentation")@fast.orchestrator( name="report_generator", instruction="Generate comprehensive reports on any topic", agents=["researcher", "analyzer", "writer"], plan_type="full", # "full" or "iterative" plan_iterations=5 # Max planning attempts)async def main(): async with fast.run() as agent: await agent.report_generator( "Create a report on renewable energy trends" )
Iteratively improve outputs through cycles of generation and evaluation.
@fast.agent( "web_searcher", "Search and compile information", servers=["fetch"])@fast.agent( "quality_assurance", """Evaluate information quality and completeness. Rate as: EXCELLENT, GOOD, FAIR, or POOR. Provide specific improvement suggestions.""")@fast.evaluator_optimizer( name="researcher", generator="web_searcher", evaluator="quality_assurance", min_rating="GOOD", # Minimum acceptable rating max_refinements=3 # Maximum iterations)async def main(): async with fast.run() as agent: result = await agent.researcher( "Research the benefits of renewable energy" )
MAKER (“Massively decomposed Agentic processes with K-voting Error Reduction”) samples a worker agent multiple times until reaching consensus.
@fast.agent( name="classifier", instruction="Reply with only: A, B, or C.")@fast.maker( name="reliable_classifier", worker="classifier", k=3, # Voting margin max_samples=25, # Maximum samples match_strategy="normalized", # exact, normalized, structured red_flag_max_length=16 # Flag long outputs)async def main(): async with fast.run() as agent: result = await agent.reliable_classifier( "Classify this text..." )
normalized: Ignore whitespace and case differences
structured: Parse and compare structured data (JSON, etc.)
MAKER is ideal for tasks where occasional errors in simple operations would compound in longer workflows. Based on research achieving zero errors over million-step tasks.
Expose child agents as tools that a parent orchestrator can call flexibly.
@fast.agent( name="NY-Project-Manager", instruction="Return NY time and project status", servers=["time"])@fast.agent( name="London-Project-Manager", instruction="Return London time and news", servers=["time"])@fast.agent( name="PMO-orchestrator", instruction=""" Get reports from project managers. Always use one tool call per project. Responsibilities: - NY projects: OpenAI, Fast-Agent, Anthropic - London news: Economics, Art, Culture Aggregate results and add PMO summary. """, default=True, agents=["NY-Project-Manager", "London-Project-Manager"], max_parallel=128, # Max parallel child calls child_timeout_sec=600, # Per-child timeout max_display_instances=20 # UI display limit)async def main(): async with fast.run() as agent: await agent("Get PMO report. Projects: all. News: Art, Culture")
async with fast.run() as agent: # Call workflow by name result = await agent.workflow_name("input") # Or use send method result = await agent.workflow_name.send("input") # Interactive mode await agent.workflow_name.prompt()
# Run specific workflowuv run app.py --agent workflow_name --message "input"# Quiet mode (no progress display)uv run app.py --agent workflow_name --message "input" --quiet# Interactive modeuv run app.py --agent workflow_name