HostedAgent(provider=...) runtimes — like e2b, modal, or flyio — without editing PraisonAI core.
HostedAgent resolves the provider and runs the agent on that backend.
Quick Start
1
Simple — Programmatic Registration
Register a backend class directly at runtime (ideal for testing or single-project use):
2
With Entry Point — pip-installable Plugin
Create a Python package with a After installation:
praisonai.managed_backends entry point so your backend is automatically available after pip install:How It Works
HostedAgent.__new__ acts as a factory for non-Anthropic backends. When the resolved backend class is different from HostedAgent, Python’s __new__ returns the backend instance directly — __init__ is skipped. Callers receive the real backend’s methods without any AnthropicManagedAgent-inherited state:
anthropic backend is pre-registered in ManagedBackendRegistry — it resolves to AnthropicManagedAgent.
Async parity. When an agent with a managed backend calls achat() / astart() / arun(), the backend’s async execute() is awaited directly through _adelegate_to_backend — no worker-thread bridge, and the same rate limiter and cancellation token that gate the sync path apply first. Session history is recorded identically on both paths, so switching an agent between sync and async does not diverge its chat_history. Before PR #3877 a configured backend was silently ignored on async entry points and calls fell through to direct-LLM.
Configuration Options
ManagedBackendRegistry API Reference
Complete API reference for ManagedBackendRegistry
Common Patterns
Custom Hosted Runtime
Selecting Between Multiple Registered Backends
Graceful Unavailable-Backend Handling
Best Practices
Entry-point naming conventions
Entry-point naming conventions
Use the provider name as the entry-point key — lowercase, no hyphens. The key becomes the value passed to
provider=:is_available() discipline
is_available() discipline
Always implement Never do heavy imports inside
is_available() with a fast, cached check. The registry calls it during startup probing:is_available() — it is called on every registry probe.Error-message hints
Error-message hints
Include helpful hints in your error messages so users know what to install:
Cleanup hooks
Cleanup hooks
Implement resource cleanup if your backend opens connections or sandbox environments:
Related
Framework Adapter Plugins
Add new execution frameworks via entry points
Hosted Agent
Run agent loops on managed cloud runtimes

