> ## 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**](../modules/protocols) module.

<Badge color="blue">AI Agent</Badge>

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

<CardGroup cols={2}>
  <Card title="execute()" icon="function" href="../functions/ManagedBackendProtocol-execute">
    Execute a prompt on managed infrastructure and return the full response.
  </Card>

  <Card title="stream()" icon="function" href="../functions/ManagedBackendProtocol-stream">
    Stream a prompt response as text chunks.
  </Card>

  <Card title="reset_session()" icon="function" href="../functions/ManagedBackendProtocol-reset_session">
    Discard the cached session so the next execute() creates a fresh one.
  </Card>

  <Card title="reset_all()" icon="function" href="../functions/ManagedBackendProtocol-reset_all">
    Discard all cached state (agent, environment, session, client).
  </Card>

  <Card title="update_agent()" icon="function" href="../functions/ManagedBackendProtocol-update_agent">
    Update an existing managed agent's configuration.
  </Card>

  <Card title="interrupt()" icon="function" href="../functions/ManagedBackendProtocol-interrupt">
    Send a user interrupt to the active session.
  </Card>

  <Card title="retrieve_session()" icon="function" href="../functions/ManagedBackendProtocol-retrieve_session">
    Retrieve the current managed session's metadata and usage.
  </Card>

  <Card title="list_sessions()" icon="function" href="../functions/ManagedBackendProtocol-list_sessions">
    List sessions for the current agent.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/protocols.py#L325">
  `praisonaiagents/agent/protocols.py` at line 325
</Card>
