> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Managed Backend Protocol • AI Agent SDK

> ManagedBackendProtocol: Protocol for external managed agent backends.

# ManagedBackendProtocol

> Defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

> [card] [execute()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-execute.md)
>
> Execute a prompt on managed infrastructure and return the full response.

> [card] [stream()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-stream.md)
>
> Stream a prompt response as text chunks.

> [card] [reset\_session()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-reset_session.md)
>
> Discard the cached session so the next execute() creates a fresh one.

> [card] [reset\_all()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-reset_all.md)
>
> Discard all cached state (agent, environment, session, client).

> [card] [update\_agent()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-update_agent.md)
>
> Update an existing managed agent's configuration.

> [card] [interrupt()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-interrupt.md)
>
> Send a user interrupt to the active session.

> [card] [retrieve\_session()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-retrieve_session.md)
>
> Retrieve the current managed session's metadata and usage.

> [card] [list\_sessions()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/ManagedBackendProtocol-list_sessions.md)
>
> List sessions for the current agent.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/protocols.py#L325)
>
> `praisonaiagents/agent/protocols.py` at line 325


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.