Skip to main content
The unified retrieve_session() schema applies to both HostedAgent and LocalAgent (the new canonical classes), as well as the deprecated ManagedAgent factory.
retrieve_session() returns the same shape on every managed agent backend so you can write code once and switch providers freely.
The user inspects a running session; every backend returns the same SessionInfo fields for tooling and dashboards.

How It Works

Quick Start

1

HostedAgent Usage

2

LocalAgent Usage


Schema

All four fields are always present with sensible defaults:

Status Values

Empty Session Defaults

Before starting any turn you still get a valid dict — no KeyError, no .get() guards:

Building a Custom Backend

Import the protocol directly from praisonaiagents.managed:

Common Patterns

Cost monitoring

Provider-agnostic logging


Best Practices

Every key is always present. info["usage"]["input_tokens"] is always safe.
Use status == "idle" before sending a new message to avoid overlapping turns.
LocalManagedAgent always returns title="". Only AnthropicManagedAgent sets it.
from praisonaiagents.managed import ManagedBackendProtocol is the stable, recommended path.

Hosted Agent

Run entire agent loops on Anthropic’s managed runtime

Local Agent

Run agent loops locally with any LLM