Skip to main content
Run the whole agent — model calls, loop and tools — inside a local Docker container you own.
docker is one of eight places run_on= can host the whole loop — see Placement for the full list (anthropic, docker, e2b, modal, daytona, flyio, tenki, novita). docker now routes through the same generic backend as every other cloud place — one code path for every runtime. Its own bespoke backend was retired in PR #4077 because its containers could be listed but not stopped: they were named in a shape DockerCompute’s lookup did not recognise.
What changed (PR #4077). docker and the cloud places now share one implementation. Behaviour for existing run_on="docker" code is unchanged; the container-lookup bug that made praisonai managed stop fail on it is fixed.
As of PR #4092, the vendor compute providers live in the standalone praisonai-sandbox package (same names, same behaviour; old praisonai.integrations.compute.* imports still work through a shim).

Quick Start

1

Minimal

One line moves the whole agent into a container.
2

With a prebuilt image

Supply your own image with praisonaiagents baked in to skip the ~1 min first-run install.
3

Extra environment and packages

Pass extra environment variables and packages, and disable container reuse.

How It Works

The agent on your machine ships its serialisable config into the container, which rebuilds the agent, calls the LLM and runs the tools — then returns the answer. The model API key travels into the container via -e KEY — the value is read from your host environment, never placed on the command line, so it never shows up in docker inspect or a process listing.

run_on="docker" vs tools_run_on="docker"

Both spellings name the same place. What differs is what crosses the boundary — the parameter name carries the scope. The object reports which scope you chose:
Which one do you want?

Configuration Options

Pass these to HostedAgent(provider="docker", ...). Since PR #4077 the generic backend honours image= too, so HostedAgent(provider="docker", image="my-org/agent:latest") behaves the same across the compute-backed places.

Model keys forwarded automatically

These variables are forwarded into the container when set in your host environment, passed with -e KEY (value read from your env), so they never appear in docker inspect or a process listing: OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY, GROQ_API_KEY, MISTRAL_API_KEY, COHERE_API_KEY, OPENROUTER_API_KEY, DEEPSEEK_API_KEY, XAI_API_KEY, OPENAI_BASE_URL, OPENAI_API_BASE.

Limitations

These are real. Hit them with eyes open.
  • Python callables in tools= do not cross into the container. A function defined in your process cannot be reconstructed remotely; the container rebuilds the agent from its serialisable config only. This is the same limitation the hosted runtimes have.
  • The container needs the model API key. Moving the loop is the point, so the key is forwarded from your host environment.
  • First run installs praisonaiagents (~1 min) unless image= supplies one that already has it.

Troubleshooting

When Docker is not running, run_on="docker" fails fast and points you at the daemon-free alternative:

Best Practices

Bake praisonaiagents into a custom image and pass it as image=. The first-run install (~1 min) disappears and start-up becomes predictable.
One container is reused across calls, so a follow-up turn does not pay start-up again. The default is already True.
When you want the loop on your machine — cheaper, and no API key inside the container — move only the tools with tools_run_on="docker".
With keep_alive=False, tear the container down with .shutdown() or use the backend as a context manager (with HostedAgent(...) as hosted:).
Since PR #4109, a weakref.finalize on the backend reclaims the container when the backend is collected or the process exits — so a keep_alive=True container no longer outlives your script..shutdown() still exists: call it when you want teardown to happen now rather than whenever GC runs.
On an older version? Reclaim any leftover containers with praisonai managed ps / managed stop. See the run_on= finalizer.

Hosted Agent

run_on="anthropic" — the vendor-hosted sibling.

Placement

One vocabulary for where the whole agent and its tools run.

Where It Runs

Ask the object where the model thinks and the tools run.

Shared Sandbox

For the tools_run_on="docker" case across a flow.

Reclaim Stray Sandboxes

Find and stop containers left behind by an older version.