Quickstart¶
Get a multi-agent workflow running in 5 minutes.
The Goal¶
We'll build a simple research-and-respond flow:
- A researcher agent gathers information
- A responder agent formulates a user-facing answer
Step 1: Define Agents¶
import agentic_flow as af
researcher = af.Agent(
name="researcher",
instructions="Research the given topic. Provide detailed findings.",
model="gpt-5.2",
)
responder = af.Agent(
name="responder",
instructions="Based on research findings, provide a clear response to the user.",
model="gpt-5.2",
)
Each Agent wraps the OpenAI Agents SDK. All SDK arguments (model, instructions, tools, etc.) pass through directly.
Step 2: Define the Flow¶
import agentic_flow as af
async def research_flow(user_message: str) -> str:
# Phase 1: Research (internal thinking, not saved to session)
async with af.phase("Research"):
findings = await researcher(user_message).stream()
# Phase 2: Response (persist=True saves to session)
async with af.phase("Response", persist=True):
return await responder(f"Research findings:\n{findings}").stream()
Key points:
phase()creates a boundary — cleanup is automatic.stream()enables streaming outputpersist=Truewrites the final result to the session
Step 3: Run with a Runner¶
import agentic_flow as af
from agents import SQLiteSession
runner = af.Runner(
flow=research_flow,
session=SQLiteSession("conversation.db"),
)
# Async execution
result = await runner("What is quantum computing?")
print(result)
# Or synchronous (for scripts/Jupyter)
result = runner.run_sync("What is quantum computing?")
print(result)
Full Example¶
import agentic_flow as af
from agents import SQLiteSession
# Define agents
researcher = af.Agent(
name="researcher",
instructions="Research the given topic. Provide detailed findings.",
model="gpt-5.2",
)
responder = af.Agent(
name="responder",
instructions="Based on research findings, provide a clear response to the user.",
model="gpt-5.2",
)
# Define flow
async def research_flow(user_message: str) -> str:
# Internal thinking - not saved to session
async with af.phase("Research"):
findings = await researcher(user_message).stream()
# persist=True saves the final response to session
async with af.phase("Response", persist=True):
return await responder(f"Research findings:\n{findings}").stream()
# Run
runner = af.Runner(
flow=research_flow,
session=SQLiteSession("conversation.db"),
)
result = runner.run_sync("What is quantum computing?")
print(result)
What Just Happened?¶
researcher(user_message)created anExecutionSpec— no execution yet.stream()added streaming mode — still no executionawaittriggered the actual executionphase("Research")wrapped the execution with automatic boundary management- The responder received the research findings and generated a response
persist=Truesaved the final exchange to the SQLite session
Next Steps¶
- Your First Flow — Deeper dive into flow structure
- Concepts — Understand Call-Spec discipline
- Streaming — Add real-time output
Next: Your First Flow