Quick Start
API Methods
Agent::simple()
One-liner agent creation:Agent::new()
Start builder for full customization:agent.chat()
Main method for interaction:agent.start() / agent.run()
Aliases forchat():
Builder Methods
| Method | Type | Description |
|---|---|---|
.name(str) | &str | Agent identifier |
.instructions(str) | &str | System instructions |
.tool(fn) | impl Tool | Add a tool |
.build() | - | Create the Agent |
Complete Example
Memory
Conversation history is automatically maintained:Best Practices
Use descriptive instructions
Use descriptive instructions
Clear instructions lead to better agent behavior. Be specific about the agent’s role and capabilities.
Add tools for external actions
Add tools for external actions
Give agents tools when they need to perform actions beyond text generation.
Handle errors gracefully
Handle errors gracefully
Always use
? or proper error handling for async operations.
