What is an Agent?
An agent is an autonomous entity that can understand natural language instructions, make decisions, and use tools to accomplish tasks. In PiCrust, agents are the core building blocks of your agentic applications.Agent Lifecycle
1
Initialization
Create an agent instance with your LLM provider configuration:
2
Tool Registration
Add tools that the agent can use:
3
Execution
Execute tasks and get responses:
4
Cleanup
Resources are automatically cleaned up when the agent is dropped.
Agent Configuration
Configure agent behavior with various options:Agent Capabilities
Decision Making
Agents can analyze situations and make autonomous decisions:Tool Usage
Agents automatically select and use appropriate tools:Context Retention
Maintain conversation context across multiple interactions:Best Practices
Provide Clear Instructions
Provide Clear Instructions
Give agents specific, actionable instructions:Good: “Read the config.json file and extract the database URL”Bad: “Do something with the config”
Enable Only Necessary Tools
Enable Only Necessary Tools
Only register tools that the agent needs to reduce complexity and improve safety:
Handle Errors Gracefully
Handle Errors Gracefully
Always handle potential errors from agent operations:
Use Appropriate Models
Use Appropriate Models
Choose the right model for your use case:
- Claude Opus: Complex reasoning tasks
- Claude Sonnet: Balanced performance and cost
- Gemini: Multimodal capabilities
Advanced Features
Custom System Prompts
Customize the agent’s behavior with system prompts:Hooks and Callbacks
Add hooks to monitor agent behavior:Next Steps
Tools
Learn about available tools
MCP Integration
Extend agents with MCP