Skip to main content
HostedAgent hosts the whole agent loop away from your process — on Anthropic, or in any registered compute runtime (Docker, E2B, Modal, Daytona, Fly.io, Tenki).
For the same shape without a vendor cloud — run the whole agent in a Docker container you own — see Self-Hosted Agent (Docker). For a provider-by-provider guide, see HostedAgent Compute Runtimes.
The user sends a request; the full agent loop runs on the chosen provider’s hosted runtime.

Quick Start

1

Simple Usage

Create a hosted agent with minimal configuration:
2

With Tools and Multi-Turn

Enable agent tools and demonstrate session continuity:

How It Works


When to Use HostedAgent vs LocalAgent


Which provider should I pick?

anthropic is one entry in the backend registry; every registered compute runtime is another.
provider="daytona" requires daytona-sdk and DAYTONA_API_KEY. Memory in ComputeConfig is specified as memory_mb (megabytes) and is converted to Daytona’s native GiB unit automatically (minimum 1 GiB). File uploads via execute_in_compute() copy the local file’s contents to the remote path — this was fixed in PR #4074; earlier versions wrote the path string to a file named after the content.

Which providers resolve vs raise

Registered compute runtimes resolve; LLM routing names raise a ValueError that points at LocalAgent. For openai, gemini, ollama, and local, use LocalAgent instead:

Configuration Options

HostedAgent API Reference

Complete HostedAgent configuration options

HostedAgentConfig Reference

Configuration object parameters

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.
  • docker is now a built-in provider alongside anthropic, resolved through the same registry (no plugin needed). HostedAgent(provider="docker") runs the whole agent in a local container — see Self-Hosted Agent (Docker).

Entry-point registration

A pip-installable package can publish a new HostedAgent provider by declaring an entry point:
After 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

When HostedAgent(provider="unknown") is called with an unregistered provider, the error lists available backends:
Cross-reference: Managed Backend Plugins — full guide to authoring and publishing provider backends.

Migrating from ManagedAgent

Replace the deprecated ManagedAgent factory with the new canonical class:

Best Practices

  • Use claude-haiku-4-5 for 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
  • Use agent_toolset_20260401 for 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
  • 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
  • Handle ValueError for 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

HostedAgent Compute Runtimes

Run the whole loop in Docker, E2B, Modal, Daytona, Fly.io, or Tenki

Placement — where does my agent run?

Agent(run_on="daytona") is the short form of this factory

Self-Hosted Agent (Docker)

run_on="docker" — the whole agent in a container you own

Where Does It Run

Ask any agent where its thinking and tools actually execute

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