Build Your First Agent
This guide builds a simple agent that can use tools to answer questions. You’ll see the full loop: user message → LLM reasoning → tool call → tool result → final response.Define a Tool
Tools are async functions decorated with@tool:
- Tools MUST be
async def - The docstring becomes the tool’s description for the LLM
Best Practicessection is injected into the system prompt as usage guidance- Return type annotation tells the framework what to expect
Define the Agent
@llm_chatcreates a multi-turn agent (vs@llm_functionfor single calls)toolkit=[...]gives the agent access to toolsstream=Trueenables streaming responseshistoryparameter name is special — the framework manages conversation state through it- The docstring is the agent’s system prompt
Run and Consume Events
@llm_chat returns an async generator of ReactOutput — either response chunks or lifecycle events:
What Happened Under the Hood
Add More Tools
What’s Next
Multi-Turn Chat
Manage longer conversations with history and streaming.
Why This Design?
Understand why LLM calls are functions, not chains.