You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PraisonAI PR MervinPraison/PraisonAI#1439 (merged, closes #1429) introduces two user-facing documentation changes to the Managed Agents backend:
Unified SessionInfo schema — retrieve_session() on both AnthropicManagedAgent and LocalManagedAgent now returns the same dictionary shape with all fields always present. Adds a new title field and a new status="unknown" default for empty sessions.
ManagedBackendProtocol re-export — the protocol interface is now importable from praisonaiagents.managed, making it the recommended path for anyone building a custom backend.
Existing docs still describe the old, partial schema (no title, no defaults, retrieve_session() returning {} when empty). The code examples in docs/concepts/managed-agents-local.mdx and docs/concepts/managed-agents.mdx are now incomplete / out-of-date and need updating. One new small feature page should also be created to give users a single, discoverable place to learn about the unified schema.
Action for follow-up docs agent: The pages that need edits are in docs/concepts/ which per AGENTS.md is human-approved-only. This issue explicitly authorises the docs agent to update the two existing concept pages listed below (minimal edits — schema/usage table additions only, no structural rewrites) AND to create a new feature page at docs/features/managed-agents-session-info.mdx. Do NOT create new files in docs/concepts/.
What Changed in the SDK (Ground Truth)
1. New SessionInfo dataclass
Source:src/praisonai/praisonai/integrations/_session_info.py (new file)
Session title/name. Empty if backend does not track titles (e.g., LocalManagedAgent).
usage
Dict[str, int]
{"input_tokens": 0, "output_tokens": 0}
Token usage counters. Both keys are always present.
2. Unified retrieve_session() behaviour
Source:src/praisonai/praisonai/integrations/managed_agents.py (AnthropicManagedAgent) and src/praisonai/praisonai/integrations/managed_local.py (LocalManagedAgent)
Before (old behaviour — currently documented):
# Anthropic backend returned partial dict
{"id": "...", "status": "idle", "usage": {"input_tokens": 10, "output_tokens": 5}}
# Local backend returned slightly different shape
{"id": "...", "status": "idle"or"none", "usage": {...}}
# Empty session → {}
After (new behaviour — needs documenting):
# BOTH backends now return identical shape, all 4 keys always present
{
"id": "session-abc",
"status": "idle",
"title": "My Session", # NEW field (empty string on LocalManagedAgent)"usage": {"input_tokens": 100, "output_tokens": 50},
}
# Empty session (no session yet)
{
"id": "",
"status": "unknown", # was missing entirely before"title": "",
"usage": {"input_tokens": 0, "output_tokens": 0},
}
# LocalManagedAgent with _session_id = None
{
"id": "",
"status": "none", # "none" means "local agent has no session""title": "",
"usage": {"input_tokens": 0, "output_tokens": 0},
}
Users can now import the protocol from the managed sub-package (previously required reaching into praisonaiagents.agent.protocols):
# NEW recommended import (PR #1439)frompraisonaiagents.managedimportManagedBackendProtocol# Old path still works (no breaking change)frompraisonaiagents.agent.protocolsimportManagedBackendProtocol
The import is lazy — ManagedBackendProtocol is not imported until first accessed, keeping the managed module lightweight.
Pages to Update
A. Update docs/concepts/managed-agents-local.mdx (existing)
Why: The "Usage Tracking" section (lines ~180–205) and "Persistent Sessions" section (lines ~125–135) show examples that assume the old partial schema (session_info.get("usage") guard, no title, no status handling).
Required edits:
In the "Usage Tracking" example, remove the .get("usage") guard — usage is now always present:
Add a short note under "Session Management" that retrieve_session()always returns all 4 keys (id, status, title, usage) with sensible defaults when no session exists.
Add a link card under "Related" → Managed Agents: SessionInfo Schema pointing to the new feature page (see section C).
B. Update docs/concepts/managed-agents.mdx (existing)
Why: The "Best Practices → Monitor Resource Usage" accordion references retrieve_session() without showing the return shape. Add a reference to the unified schema.
Required edits:
Update the retrieve_session() line in the "Monitor Resource Usage" accordion:
Track token usage with `retrieve_session()` — returns a unified schema
(`id`, `status`, `title`, `usage`) on all backends. See the
[SessionInfo Schema page](/docs/features/managed-agents-session-info) for details.
In the Configuration Options table OR as a new sub-section, mention that ManagedBackendProtocol can be imported from praisonaiagents.managed:
# Build a custom managed backend by implementing this protocol
from praisonaiagents.managed import ManagedBackendProtocol
C. Create new docs/features/managed-agents-session-info.mdx (new file)
Why: Users need a single discoverable page explaining:
The unified return shape
All field semantics and values
Cross-backend consistency guarantees
The new ManagedBackendProtocol import path for custom backends
Full page draft (follows AGENTS.md template):
Click to expand full page draft
---title: "Managed Agent Session Info"sidebarTitle: "Session Info Schema"description: "Unified session schema returned by managed agent backends"icon: "circle-info"---`retrieve_session()` returns the same shape on every managed agent backend so you can write code once and switch providers freely.
```mermaidgraph LR subgraph "Unified SessionInfo" A[📝 retrieve_session] --> B{🧠 Backend} B -->|Anthropic| C[SessionInfo dict] B -->|Local| C C --> D[id] C --> E[status] C --> F[title] C --> G[usage] end classDef call fill:#6366F1,stroke:#7C90A0,color:#fff classDef backend fill:#F59E0B,stroke:#7C90A0,color:#fff classDef result fill:#10B981,stroke:#7C90A0,color:#fff classDef field fill:#189AB4,stroke:#7C90A0,color:#fff class A call class B backend class C result class D,E,F,G field```## Quick Start
<Steps>
<Steptitle="Read a session">
```pythonfrom praisonaiagents import Agent
from praisonai.integrations.managed_agents import ManagedAgent, ManagedConfig
managed = ManagedAgent(config=ManagedConfig(model="claude-sonnet-4-6"))
agent = Agent(name="assistant", backend=managed)
agent.start("Hello!")
info = managed.retrieve_session()
print(info["id"], info["status"], info["title"])
print(info["usage"]["input_tokens"], info["usage"]["output_tokens"])
```
</Step>
<Steptitle="Works the same on LocalManagedAgent">
```pythonfrom praisonai.integrations.managed_local import LocalManagedAgent
local = LocalManagedAgent()
info = local.retrieve_session()
# Same 4 keys — id, status, title, usage — every time```
</Step>
</Steps>
---## Schema
All four fields are **always present** with sensible defaults:
| Field | Type | Default | Values ||-------|------|---------|--------||`id`|`str`|`""`| Session ID, empty if none ||`status`|`str`|`"unknown"`|`idle`, `running`, `error`, `unknown`, `none`||`title`|`str`|`""`| Session title (Anthropic only sets this) ||`usage`|`Dict[str, int]`|`{"input_tokens": 0, "output_tokens": 0}`| Always has both keys |## Status Values```mermaidgraph TB Start[No Session] -->|unknown| A[status: unknown] Start -->|none| B[status: none] Active[Session Active] -->|idle| C[status: idle] Active -->|running| D[status: running] Active -->|error| E[status: error] classDef empty fill:#F59E0B,stroke:#7C90A0,color:#fff classDef active fill:#10B981,stroke:#7C90A0,color:#fff class A,B empty class C,D,E active```| Status | Meaning ||--------|---------||`idle`| Session exists and ready for input ||`running`| Session actively processing (Anthropic) ||`error`| Session hit an error (Anthropic) ||`unknown`| No session / status unavailable ||`none`| Local backend with no session ID |## Empty Session Defaults
Before starting any turn you still get a valid dict — no `KeyError`, no `.get()` guards:
```python
managed = ManagedAgent(config=ManagedConfig())
info = managed.retrieve_session()
# {"id": "", "status": "unknown", "title": "", "usage": {"input_tokens": 0, "output_tokens": 0}}```## Building a Custom BackendImporttheprotocoldirectlyfrom`praisonaiagents.managed`:
```pythonfrom praisonaiagents.managed import ManagedBackendProtocol
from typing import Dict, Any
classMyBackend:
defretrieve_session(self) -> Dict[str, Any]:
# Return the unified shapereturn {
"id": "my-session",
"status": "idle",
"title": "My Session",
"usage": {"input_tokens": 0, "output_tokens": 0},
}
# ... implement execute(), stream(), reset_session(), reset_all()```## Common Patterns### Cost monitoring```python
info = managed.retrieve_session()
cost = info["usage"]["input_tokens"] *3e-6+ info["usage"]["output_tokens"] *15e-6print(f"Session {info['id']} spent ${cost:.4f}")
```### Provider-agnostic logging```pythondeflog_session(backend):
info = backend.retrieve_session()
print(f"[{info['status']}] {info['title'] or info['id']}")
log_session(anthropic_backend)
log_session(local_backend) # Same code — both return identical shape```---## Best Practices
<AccordionGroup>
<Accordiontitle="Don't guard with .get()">
Every key is always present. `info["usage"]["input_tokens"]` is always safe.
</Accordion>
<Accordiontitle="Check status before acting">
Use `status == "idle"` before sending a new message to avoid overlapping turns.
</Accordion>
<Accordiontitle="Titles are optional">
`LocalManagedAgent` always returns `title=""`. Only `AnthropicManagedAgent` sets it.
</Accordion>
<Accordiontitle="Import the protocol from praisonaiagents.managed">
`from praisonaiagents.managed import ManagedBackendProtocol` is the stable, recommended path.
</Accordion>
</AccordionGroup>
---## Related
<CardGroupcols={2}>
<Cardtitle="Managed Agents"icon="cloud"href="/docs/concepts/managed-agents">
Overview of managed agent backends
</Card>
<Cardtitle="Local Managed Agents"icon="desktop"href="/docs/concepts/managed-agents-local">
Run managed agents locally
</Card>
</CardGroup>
D. Add navigation entry
Add an entry under the Features group in docs.json:
docs/concepts/managed-agents-local.mdx — "Usage Tracking" and "Persistent Sessions" examples updated to reflect the unified schema (no .get() guards, show status/title).
docs/concepts/managed-agents.mdx — "Monitor Resource Usage" accordion and Configuration Options reference the unified schema and praisonaiagents.managed import.
docs/features/managed-agents-session-info.mdx — new page created following the draft above, uses Mintlify components (Steps, AccordionGroup, CardGroup), includes hero Mermaid + status-flow Mermaid with the standard color scheme.
docs.json — new page added under the Features group only (do not touch Concepts).
All code examples run without modification (paste-and-run).
All field types and defaults match src/praisonai/praisonai/integrations/_session_info.py exactly.
No mention of undocumented fields or undocumented statuses.
Page passes the AGENTS.md Quality Checklist (frontmatter, hero diagram, Quick Start Steps, schema table, Best Practices accordions, Related card group).
Overview
PraisonAI PR MervinPraison/PraisonAI#1439 (merged, closes #1429) introduces two user-facing documentation changes to the Managed Agents backend:
SessionInfoschema —retrieve_session()on bothAnthropicManagedAgentandLocalManagedAgentnow returns the same dictionary shape with all fields always present. Adds a newtitlefield and a newstatus="unknown"default for empty sessions.ManagedBackendProtocolre-export — the protocol interface is now importable frompraisonaiagents.managed, making it the recommended path for anyone building a custom backend.Existing docs still describe the old, partial schema (no
title, no defaults,retrieve_session()returning{}when empty). The code examples indocs/concepts/managed-agents-local.mdxanddocs/concepts/managed-agents.mdxare now incomplete / out-of-date and need updating. One new small feature page should also be created to give users a single, discoverable place to learn about the unified schema.What Changed in the SDK (Ground Truth)
1. New
SessionInfodataclassSource:
src/praisonai/praisonai/integrations/_session_info.py(new file)Field table (for docs):
idstr""statusstr"unknown""idle","running","error","unknown","none".titlestr""LocalManagedAgent).usageDict[str, int]{"input_tokens": 0, "output_tokens": 0}2. Unified
retrieve_session()behaviourSource:
src/praisonai/praisonai/integrations/managed_agents.py(AnthropicManagedAgent) andsrc/praisonai/praisonai/integrations/managed_local.py(LocalManagedAgent)Before (old behaviour — currently documented):
After (new behaviour — needs documenting):
Status values to document:
"idle""running""error""unknown""none"_session_id = None3.
ManagedBackendProtocolre-exportSource:
src/praisonai-agents/praisonaiagents/managed/__init__.pyUsers can now import the protocol from the
managedsub-package (previously required reaching intopraisonaiagents.agent.protocols):The import is lazy —
ManagedBackendProtocolis not imported until first accessed, keeping themanagedmodule lightweight.Pages to Update
A. Update
docs/concepts/managed-agents-local.mdx(existing)Why: The "Usage Tracking" section (lines ~180–205) and "Persistent Sessions" section (lines ~125–135) show examples that assume the old partial schema (
session_info.get("usage")guard, notitle, nostatushandling).Required edits:
In the "Usage Tracking" example, remove the
.get("usage")guard —usageis now always present:Add a short note under "Session Management" that
retrieve_session()always returns all 4 keys (id,status,title,usage) with sensible defaults when no session exists.Add a link card under "Related" →
Managed Agents: SessionInfo Schemapointing to the new feature page (see section C).B. Update
docs/concepts/managed-agents.mdx(existing)Why: The "Best Practices → Monitor Resource Usage" accordion references
retrieve_session()without showing the return shape. Add a reference to the unified schema.Required edits:
Update the
retrieve_session()line in the "Monitor Resource Usage" accordion:In the Configuration Options table OR as a new sub-section, mention that
ManagedBackendProtocolcan be imported frompraisonaiagents.managed:C. Create new
docs/features/managed-agents-session-info.mdx(new file)Why: Users need a single discoverable page explaining:
ManagedBackendProtocolimport path for custom backendsFull page draft (follows AGENTS.md template):
Click to expand full page draft
D. Add navigation entry
Add an entry under the Features group in
docs.json:{ "group": "Features", "pages": [ "…existing…", "docs/features/managed-agents-session-info" ] }User Interaction Flow (as required by
AGENTS.mdrule 11)Typical sequence a user will write against:
SDK Source References
src/praisonai/praisonai/integrations/_session_info.pySessionInfodataclass (fields, defaults,to_dict())src/praisonai/praisonai/integrations/managed_agents.pylines ~565–605AnthropicManagedAgent.retrieve_session()implementationsrc/praisonai/praisonai/integrations/managed_local.pylines ~690–715LocalManagedAgent.retrieve_session()implementationsrc/praisonai-agents/praisonaiagents/managed/__init__.pyManagedBackendProtocolsrc/praisonai-agents/tests/managed/test_session_info_schema.pysrc/praisonai-agents/tests/unit/test_managed_backend.pyline ~511test_retrieve_session_no_session(updated expectation)Acceptance Criteria
docs/concepts/managed-agents-local.mdx— "Usage Tracking" and "Persistent Sessions" examples updated to reflect the unified schema (no.get()guards, showstatus/title).docs/concepts/managed-agents.mdx— "Monitor Resource Usage" accordion and Configuration Options reference the unified schema andpraisonaiagents.managedimport.docs/features/managed-agents-session-info.mdx— new page created following the draft above, uses Mintlify components (Steps, AccordionGroup, CardGroup), includes hero Mermaid + status-flow Mermaid with the standard color scheme.docs.json— new page added under the Features group only (do not touchConcepts).src/praisonai/praisonai/integrations/_session_info.pyexactly.References