Managed Backend Protocol • AI Agent SDK

ManagedBackendProtocol: Protocol for external managed agent backends.

ManagedBackendProtocol

Defined in the protocols module.

AI Agent

Protocol for external managed agent backends.

Defines the contract between PraisonAI Agent’s delegation layer (`execution_mixin._delegate_to_backend`) and any managed agent infrastructure provider (Anthropic Managed Agents, etc.).

The Core SDK defines what — this protocol. The Wrapper implements how — the provider-specific adapter.

Lifecycle::

backend = SomeManagedBackend(config={…}) agent = Agent(name=”coder”, backend=backend) result = agent.start(“Write a script”) # delegates to backend.execute()

Implementations must handle:

  • Agent/environment/session creation and caching
  • Event streaming (agent.message, agent.tool_use, session.status_idle)
  • Custom tool calls (agent.custom_tool_use → user.custom_tool_result)
  • Tool confirmation (always_ask policy → user.tool_confirmation)
  • Usage tracking (input_tokens, output_tokens)
  • Session reset for multi-turn isolation

Example::

python
class MockManagedBackend:
    async def execute(self, prompt: str, **kwargs) -> str:
        return "mock response"

    async def stream(self, prompt: str, **kwargs):
        yield "mock "
        yield "response"

    def reset_session(self) -> None:
        pass

    def reset_all(self) -> None:
        pass

assert isinstance(MockManagedBackend(), ManagedBackendProtocol)

Methods

Source

View on GitHub

praisonaiagents/agent/protocols.py at line 325