Quick Start
How It Works
| Component | Location | Purpose |
|---|---|---|
| Agent Loop | Anthropic Cloud | Complete execution environment |
| Tools | Anthropic Cloud | Sandboxed tool execution |
| LLM | Anthropic Cloud | Claude model processing |
| Session State | Anthropic Cloud | Persistent conversation context |
When to Use HostedAgent vs LocalAgent
Configuration Options
HostedAgent API Reference
Complete HostedAgent configuration options
HostedAgentConfig Reference
Configuration object parameters
| Option | Type | Default | Description |
|---|---|---|---|
model | str | "claude-haiku-4-5" | Claude model to use |
system | str | "You are a helpful coding assistant." | System prompt |
name | str | "Agent" | Agent display name |
tools | List[Dict] | [{"type": "agent_toolset_20260401"}] | Available tools |
packages | Dict | None | Package dependencies |
networking | Dict | Unrestricted | Network configuration |
Common Patterns
Multi-turn Conversation
Anthropic maintains session state in the cloud between calls:Usage Tracking
Retrieve session information and usage metrics:Session Management
List and manage active sessions:Pluggable Provider Backends
HostedAgent uses ManagedBackendRegistry to look up provider backends — third-party packages can register new providers via the praisonai.managed_backends entry-point group.
Entry-point registration
A pip-installable package can publish a newHostedAgent provider by declaring an entry point:
pip install e2b-praisonai, HostedAgent(provider="e2b") resolves it automatically — no core change needed.
Factory semantics
For non-Anthropic backends,HostedAgent.__new__ acts as a factory — it returns the resolved backend instance directly. Python skips __init__ when __new__ returns a non-cls instance, so callers get the real backend’s methods rather than Anthropic-inherited ones:
Programmatic registration
Register a backend without an entry point for testing or embedding:Error message
WhenHostedAgent(provider="unknown") is called with an unregistered provider, the error lists available backends:
Migrating from ManagedAgent
Replace the deprecatedManagedAgent factory with the new canonical class:
Best Practices
Managing API Costs
Managing API Costs
- Use
claude-haiku-4-5for simple tasks to minimize costs - Implement usage tracking with
retrieve_session()to monitor token consumption - Set appropriate tool policies to control execution overhead
- Archive old sessions to avoid accumulating state storage costs
Choosing Tools
Choosing Tools
- Use
agent_toolset_20260401for general-purpose tool access - Specify minimal tool sets to reduce complexity and cost
- Test tool combinations in development before production deployment
- Review tool execution logs via session metadata
Session Reuse
Session Reuse
- Reuse sessions for related conversations to maintain context
- Implement session ID management for user-specific contexts
- Use
resume_session()to continue conversations across application restarts - Archive sessions when conversations are complete
Error Handling
Error Handling
- Handle
ValueErrorfor unsupported providers gracefully - Implement retry logic for transient network issues
- Use
interrupt()to stop long-running operations - Monitor session status and handle error states appropriately
Related
Local Agent
Run agent loops locally with any LLM
Managed Backend Plugins
Add new HostedAgent providers via entry points
ManagedAgent Persistence
Database integration with hosted agents
Session Info
Session metadata and usage tracking

