Agent
The heart of ConnectOnion. Give it tools, and it figures out the rest.
Quick Start (60 Seconds)
That's it. Your first AI agent in 5 lines.
What Agent Can Do - Full API Overview
After that simple example, here's everything an Agent can do:
Creating an Agent
Using Your Agent
Managing Tools
Conversations & State
Attributes You Can Access
That's the complete API.
Now let's dive into each feature below. Jump to any section that interests you!
max_iterations
What Are Iterations?
Think of iterations as "attempts" - how many times your agent can use tools to complete a task.
The Basics (90% of cases)
When You Need More Power
Quick Override for One Task
When to Adjust max_iterations
- Your agent runs complex, multi-step workflows
- Tasks require multiple tool calls (research, analysis, etc.)
- You see "reached max iterations" in logs
- Agent loops unnecessarily (calls same tool repeatedly)
- You want faster failures for debugging
- Simple tasks that should complete quickly
Best Practices
- Start with default (10) - it works for most use cases
- Monitor your logs - check how many iterations tasks actually use
- Set per-agent for specialized agents (researcher=25, calculator=5)
- Override per-task when you know a specific task needs more/less
Complete Documentation
This page provides a quick overview of the Agent class. For comprehensive documentation including:
Use the "Copy" button above to get the full markdown documentation with all details, examples, and patterns.
Learn More
Philosophy
"Keep simple things simple, make complicated things possible"
Simple Case
agent = Agent("bot", tools=[search])
agent.input("Find Python docs")Complex Case
trust_agent = Agent("verifier", ...)
agent = Agent(
name="production",
llm=custom_llm,
tools=[deploy, rollback],
system_prompt=Path("ops.md"),
max_iterations=30,
trust=trust_agent,
log="/var/log/production.log"
)Both are valid. Start simple, add complexity only when needed.
ConnectOnion: AI Agent = Prompt + Function
That's it. That's the framework. Now go build something useful.
