Agentflow Tutorials¶
Welcome to Agentflow! This tutorial series will guide you through building intelligent agents and multi-agent workflows, from simple Agent class usage to advanced patterns like streaming, persistence, and tool integration.
🎯 Choose Your Path¶
Agentflow offers two approaches to building agents:
| Path | Best For | Time to First Agent |
|---|---|---|
| ⭐ Quick Path (Agent Class) | Most use cases, rapid prototyping, production apps | 5 minutes |
| 🔧 Advanced Path (Custom Functions) | Complex custom logic, non-LiteLLM providers, fine-grained control | 30+ minutes |
Recommendation
Start with the Agent class! It handles 90% of use cases with minimal code. You can always switch to custom functions later when you need more control.
🎯 What You'll Learn¶
Agentflow is a lightweight Python framework for building agent graphs. By the end of these tutorials, you'll understand how to:
- Build agents quickly using the Agent class (recommended)
- Create custom agent workflows using
StateGraphand nodes - Manage conversation state and message flow with
AgentState - Create tool-calling agents using
ToolNodeand dependency injection - Add persistence with checkpointers and memory stores
- Stream real-time responses and monitor execution events
- Use prebuilt agent patterns for common scenarios
🚀 Prerequisites¶
Before diving in, ensure you have:
- Python 3.12+ installed
- Basic familiarity with async/await patterns
- Experience with LLM APIs (OpenAI, Gemini, etc.)
- Comfort with command-line tools and environment variables
Quick Setup¶
-
Install Agentflow with LiteLLM support:
-
Set up environment variables in
.env: -
Clone examples to experiment:
📚 Tutorial Path¶
⭐ Quick Path: Agent Class (Recommended)¶
Start here for the fastest path to building agents:
- Agent Class ⭐ - Build complete agents in 10-30 lines of code
- React with Agent Class - ReAct pattern made simple
- Tool Decorator - Organize tools with metadata and tags
🔧 Advanced Path: Custom Functions¶
For when you need full control:
- Graph Fundamentals - Build agents with
StateGraph, nodes, and edges - State & Messages - Master conversation state and message schemas
- Tools & Dependency Injection - Create tool-calling agents with
ToolNode - React Agent Patterns - Complete guide to ReAct agents
🔀 Control & Flow¶
- Control Flow & Routing - Conditional edges, interrupts, and error handling
- Persistence & Memory - Save state with checkpointers and stores
- Streaming & Events - Real-time responses and observability
🎯 Advanced Patterns¶
- Prebuilt Agents & Orchestration - Ready-to-use patterns and multi-agent workflows
💡 Learning Tips¶
- Run the examples: Every tutorial references working code in
examples/. Clone, modify, and experiment! - Start with Agent class: Build your first agent in 5 minutes, then learn the internals
- Use the console: The
ConsolePublishershows you what's happening under the hood - Debug with state: Use
ResponseGranularity.FULLto inspect complete execution state
📖 Additional Resources¶
- API Reference - Detailed documentation for all classes and methods
- Examples Directory - Runnable code for every major pattern
- PyProject.toml - Optional dependencies and their features
🔗 Quick Navigation¶
| Tutorial | Focus | Key Files |
|---|---|---|
| Agent Class ⭐ | Simple agent creation | examples/agent-class/graph.py |
| React with Agent Class | ReAct made simple | examples/agent-class/ |
| Graph Fundamentals | StateGraph, nodes, compilation | examples/react/react_sync.py |
| State & Messages | AgentState, message handling | agentflow/state/ |
| Tools & DI | ToolNode, dependency injection | examples/react-injection/ |
| Tool Decorator | Metadata, tags, filtering | examples/tool-decorator/ |
| React Agents | Complete ReAct guide | examples/react*/ |
| Persistence | Checkpointers, stores | agentflow/checkpointer/ |
| Streaming | Real-time responses | examples/react_stream/ |
| Advanced | Prebuilt agents | agentflow/prebuilt/agent/ |
Ready to build your first agent? Start with Agent Class for the quickest path, or Graph Fundamentals if you want to understand the internals!