What Is an Agent?
An Agent is an autonomous AI worker that understands natural language tasks, decides which tools to use, maintains context across multi-turn conversations, and executes actions safely with configurable approval workflows. All agents share a common loop:Approve & Execute
Approval callbacks gate execution. Approved tools run; results are appended to history.
Agent Types at a Glance
| Feature | BasicAgent | Agent | SmartAgent | CopilotAgent | MCPAgent |
|---|---|---|---|---|---|
| Multi-turn chat | ✓ | ✓ | ✓ | ✓ | ✓ |
| Custom tools | ✓ | ✓ | ✓ | ✓ | ✓ |
| Auto-schema from functions | ✓ | ✓ | ✓ | ✓ | ✓ |
| Built-in tools (web, bash, notes…) | ✓ | ✓ | ✓ | ||
| Web search | ✓ | ✓ | ✓ | ||
| Bash execution | ✓ | ✓ | ✓ | ||
| Cron scheduling | ✓ | ✓ | ✓ | ✓ | |
| Persistent memory | ✓ | ✓ | ✓ | ✓ | |
| Approval workflows | ✓ | ✓ | ✓ | ✓ | |
| Streaming | ✓ | ✓ | ✓ | ✓ | |
| Skills | ✓ | ✓ | ✓ | ✓ | |
| Project mode | ✓ | ||||
| Coding convenience methods | ✓ | ||||
| MCP servers | ✓ | ||||
| Custom approval callbacks | ✓ | ✓ | ✓ | ✓ | ✓ |
When to Use Each Agent
BasicAgent
Best for: Learning, prototypes, simple Q&A bots.Minimum viable configuration — just pick a provider and call
chat(). No tools, no approval callbacks, no memory required.Setup time: ~2 minutesAgent
Best for: Production applications with custom tools.Full-featured base class. Bring your own Python functions as tools, wire up approval callbacks, enable persistent memory, and stream tokens to the UI.Setup time: ~5 minutes
SmartAgent
Best for: Developer assistants, project-scoped work, iterative tasks.Ships with web search, bash, notes, datetime, cron, and memory tools out of the box. Supports
solo and project modes with automatic learning capture.Setup time: ~5 minutesCopilotAgent
Best for: Coding assistants, file operations, code review and generation.Pre-loaded with filesystem and execution tools, a coding-focused system prompt, and convenience methods:
explain_code(), review_file(), write_code(), fix_bug().Setup time: ~3 minutesMCPAgent
Best for: Workflows that require many external tools via MCP servers.Connects to MCP servers for external tool integrations. Supports deferred tool loading to handle hundreds of tools without hitting context limits.Setup time: ~10 minutes
Quick Code Examples
Execution Pipeline
When you callagent.chat(), here is what happens internally:
max_iterations times (default 40) before returning "Max iterations reached.".
Approval & Safety Model
By default, every tool that is not on the built-in safe list requires explicit approval. You have two options:Streaming
All agent types that support streaming accept anon_token callback or a streaming_funct shorthand:
Memory
Agents support two memory layers:| Layer | Scope | How to enable |
|---|---|---|
| Session memory | Current conversation | Automatic — history is kept per session_id |
| Persistent memory | Across sessions | Pass memory=True to the constructor |
Next Steps
- BasicAgent — minimal setup,
@tooldecorator, factory function - Agent — constructor params, all methods, multi-session patterns
- SmartAgent — modes, built-in tools, project workflows
- MCPAgent — MCP servers, deferred tool loading, dynamic tool discovery