Understanding Agents
Master proven strategies for designing advanced, specialized AI agents using an architecture that work together seamlessly to tackle complex challenges.
What are Agents?
Agents are autonomous execution units that orchestrate LLM interactions with tool calling.
Without tools, an agent functions as a basic LLM. The simplest agent requires just a name and model:
You can specify any model using the "provider/model" format. See all supported models in Model Capabilities.
Some models require specific parameters (like max_tokens
for Claude). Use model_params
to pass any additional model configuration:
Note: Make sure to define all required environment variables—such as the API key model that you need—in your .env
file.
Define tools as Python functions - the framework handles schema generation, parameter validation, and execution orchestration.
Quick Example
The framework performs automatic introspection of function signatures and docstrings for tool schema generation.
What happens behind the scenes:
start_event ... path=demo_agent ...
start_event ... path=demo_agent.llm ...
output_event ... path=demo_agent.llm ...
start_event ... path=demo_agent.celsius_to_fahrenheit ...
output_event ... path=demo_agent.celsius_to_fahrenheit ...
start_event ... path=demo_agent.llm ...
output_event ..., path=demo_agent.llm ...
output_event ... path=demo_agent ...
Architecture features
-
Execution Engine:
- Asynchronous concurrent tool execution via multiplexed event queues
- Conversation state management with automatic memory persistence across iterations
- Multi-provider LLM routing with unified interface abstraction
-
Tool System:
- Runtime tool discovery with automatic OpenAI/Anthropic schema generation
- Support for nested Runnable composition and hierarchical agent orchestration
- Dynamic parameter validation using Pydantic models
-
Advanced Runtime:
- Template-based system prompt composition with runtime callable injection
- Configurable iteration limits with autonomous termination detection
- Event-driven streaming architecture with real-time processing capabilities
- Pre/post execution hooks for cross-cutting concerns and runtime interception
Running an Agent
Agent provides a streamlined execution interface:
Get a Complete Answer
Real-Time (Streaming) Output
Below are the events that get printed when you run this example:
type='START' ... path='demo_agent' ...
type='OUTPUT' ... path='demo_agent' ...
Next Steps
- Try creating your own Agent with different tools
- See examples in Examples