HostedAgent Compute Runtimes

Run the whole agent loop in Docker, E2B, Modal, Daytona, Fly.io, or Tenki — one class, one string

HostedAgent hosts the whole agent loop in any registered compute runtime — pick one with a single string.

Diagram

🌐 HostedAgent
provider=…

🔀 Backend Registry

☁️ anthropic

📦 docker

🖥️ e2b

⚡ modal

🗄️ daytona

✈️ flyio

🌩️ tenki

Quick Start

  1. Anthropic-hosted loop
    python
    from praisonaiagents import Agent
    from praisonai import HostedAgent
    
    agent = Agent(backend=HostedAgent(provider="anthropic"))
    agent.start("Summarise today's meeting notes.")
  2. Daytona-hosted loop
    python
    from praisonaiagents import Agent
    from praisonai import HostedAgent, HostedAgentConfig
    
    agent = Agent(backend=HostedAgent(
        provider="daytona",
        config=HostedAgentConfig(model="gpt-4o-mini", name="RemoteDev"),
    ))
    agent.start("Set up a Python project and run pytest.")

Which provider should I pick?

The scenario picks the string.

Diagram

Anthropic’s managed cloud

My own Docker daemon

Persistent dev workspace

Instant cloud VM

Serverless burst

Fly Machines

Tenki cloud

What do you need?

provider=anthropic

provider=docker

provider=daytona

provider=e2b

provider=modal

provider=flyio

provider=tenki


How it resolves — the backend registry

HostedAgent(provider=...) is a factory: it looks the provider up in ManagedBackendRegistry and returns the resolved backend.

Diagram
BackendRegistryHostedAgentUserBackendRegistryHostedAgentUserHostedAgent(provider=”daytona”)is_available(“daytona”)?Trueresolve + buildbackend instance

anthropic is a builtin; every registered compute runtime — docker included as of PR #4077 — resolves through the same registry and runs on one generic backend.


Provider matrix

ProviderExtra installEnv varPersistentBest for
anthropic(builtin)ANTHROPIC_API_KEY❌Anthropic-hosted loops
dockerpip install 'praisonai[docker]'(local daemon)❌Local isolation
e2bpip install 'praisonai[e2b]'E2B_API_KEY❌Instant cloud VM
modalpip install 'praisonai[modal]'Modal auth❌Serverless burst
daytonapip install 'praisonai[daytona]'DAYTONA_API_KEY✅Persistent dev workspaces
flyioFly.io tokenFLY_API_TOKEN❌Fly Machines
tenkiTenki credentialsTenki auth❌Tenki cloud

Custom image / template

Since PR #4077 the generic backend honours image= — one string maps to each provider’s native concept.

Providerimage= honoured as
dockerDocker image ref
e2bE2B template name (unless metadata["e2b_template"] is set)
modalRegistry image ref via Image.from_registry(...)
daytona, flyio, tenkiNot applicable (uses provider-native workspace/image handling)
python
from praisonaiagents import Agent
from praisonai import HostedAgent, HostedAgentConfig

# Same string across providers — each maps it to the right native concept.
agent = Agent(backend=HostedAgent(
    provider="modal",
    config=HostedAgentConfig(model="gpt-4o-mini"),
    image="ghcr.io/my-org/my-runtime:latest",
))
agent.start("Do something in my custom image.")

The default image is python:3.12-slim; image= is honoured only when set to something other than that default.


Daytona notes

Two Daytona defects were fixed in PR #4074.


What HostedAgent will NOT accept

openai, gemini, ollama, and local are LLM routing names, not runtimes. HostedAgent raises ValueError("... not yet available. Use LocalAgent ...").

python
from praisonai import LocalAgent, LocalAgentConfig

agent = LocalAgent(config=LocalAgentConfig(model="openai/gpt-4o"))
agent.start("Draft a release note.")

Common Patterns

Swap the provider without touching agent code

The provider is one string; the agent stays the same.

python
from praisonaiagents import Agent
from praisonai import HostedAgent, HostedAgentConfig

def build(provider: str) -> Agent:
    return Agent(backend=HostedAgent(
        provider=provider,
        config=HostedAgentConfig(model="gpt-4o-mini"),
    ))

agent = build("daytona")
agent.start("Run the test suite.")

Pick the provider per environment

Read the provider from an env var to switch cloud vs local.

python
import os
from praisonaiagents import Agent
from praisonai import HostedAgent

provider = os.environ.get("HOSTED_PROVIDER", "anthropic")
agent = Agent(backend=HostedAgent(provider=provider))
agent.start("Summarise the changelog.")

Best Practices

Prefer anthropic for zero-setup hosted loops

provider="anthropic" needs only ANTHROPIC_API_KEY — no extra install, no daemon. Reach for a compute runtime when you need your own isolation, persistence, or a specific cloud.

Keep the provider swappable

Pass the provider as a plain string from config or an env var. Every registered runtime shares the same HostedAgent(provider=..., config=...) shape, so switching clouds never touches agent code.

Use LocalAgent for LLM-only routing

openai, gemini, ollama, and local are not runtimes. Use LocalAgent(config=LocalAgentConfig(model="...")) for those, and add compute="..." when you want cloud-sandboxed tools with a local loop.

Daytona for persistent workspaces

daytona is the only runtime in the matrix that persists between runs — pick it when you want a dev workspace to survive across sessions. Remember memory_mb is megabytes; the provider converts to GiB.


Related