Skip to content

docs: Add praisonai managed CLI reference (sessions/agents/envs CRUD + delete/update parity) #163

@MervinPraison

Description

@MervinPraison

Context

Upstream PR MervinPraison/PraisonAI#1441 (merged 2026-04-17, closes #1430) added delete/update CLI parity to the praisonai managed command group. There is currently no user-facing documentation for the praisonai managed CLI in PraisonAIDocs — only the Python-SDK ManagedAgent persistence page at docs/features/managed-agent-persistence.mdx, which is scoped to the library-level class, not the CLI.

This issue tracks creating a new feature page that covers the full praisonai managed CLI surface, so users can manage Anthropic-hosted sessions, agents, and environments from the terminal.

What changed upstream (PR #1441)

Four new CLI subcommands were added in src/praisonai/praisonai/cli/commands/managed.py:

Command Args Options Purpose
praisonai managed sessions delete <session_id> session_id (e.g. sesn_01AbCdEf) --yes / -y Delete an Anthropic-managed session (with confirmation prompt unless --yes).
praisonai managed agents delete <agent_id> agent_id (e.g. agent_01AbCdEf) --yes / -y Delete a managed agent.
praisonai managed envs update <env_id> env_id (e.g. env_01AbCdEf) --packages / -p (comma-separated pip packages), --networking (full or limited) Update environment packages and/or networking.
praisonai managed envs delete <env_id> env_id --yes / -y Delete an environment.

Behaviours to document:

  • All three delete commands prompt Are you sure you want to delete <id>? unless --yes/-y is passed. Typing n (or anything non-affirmative) prints Deletion cancelled. and exits 0.
  • envs update with no --packages and no --networking prints Nothing to update. Pass --packages or --networking. and exits 0.
  • envs update --networking only accepts full or limited; anything else exits 1 with Error: --networking must be 'full' or 'limited'.
  • envs update --packages "a, ,b,," trims whitespace and filters empty entries (so it sends ["a", "b"]). If all entries are empty it errors with --packages must include at least one package name and exits 1.
  • API errors from the underlying Anthropic client exit 1 and print Error <verb> <resource>: <message>.
  • The CLI uses _get_client(), which reads ANTHROPIC_API_KEY first and falls back to CLAUDE_API_KEY; if neither is set (or the anthropic package isn't installed) the command exits 1.

These sit alongside the already-existing (but also undocumented) subcommands in the same module: sessions list/get/resume, agents list/get/create/update, envs list/get, and the ids save/restore/show helpers. The new page should document the whole praisonai managed surface, not just the PR's four commands, so users get one coherent reference.

Decision: create new content (not update)

  • docs/features/managed-agent-persistence.mdx is SDK/class-focused (ManagedAgent, ManagedConfig, db(...)). It should not be repurposed.
  • There is no docs/cli/managed.mdx or equivalent. This is net-new.
  • Per AGENTS.md §1.8, new pages go in docs/features/ (never docs/concepts/). Proposed path: docs/features/managed-cli.mdx.
  • Add the new page to docs.json under the Features group (not Concepts). Verify docs.json remains valid JSON after editing.
  • Cross-link from docs/features/managed-agent-persistence.mdx → the new CLI page, and vice versa, under a Related CardGroup.

SDK source to read first (SDK-First Documentation Cycle — AGENTS.md §1.2)

Before writing a single line, the implementing agent must read:

  1. praisonai/cli/commands/managed.py — full command module (synced daily from upstream into this repo at repo-root praisonai/cli/commands/managed.py; also available in the upstream repo at src/praisonai/praisonai/cli/commands/managed.py).
  2. PR diff: https://github.com/MervinPraison/PraisonAI/pull/1441/files — confirms exact flag names, help strings, error messages, and exit codes.
  3. src/praisonai/tests/unit/cli/test_managed_cli_destructive.py in PR #1441 — 22 tests that document the observable behaviour (confirmation flow, error paths, package trimming, _get_client env-var precedence). Use these as the source of truth for "what does the CLI actually print and exit with."

Do not invent flags or exit codes — copy them from source.

Required page structure (per AGENTS.md §2)

---
title: "Managed CLI"
sidebarTitle: "Managed CLI"
description: "Manage Anthropic-hosted sessions, agents, and environments from the terminal"
icon: "terminal"
---

{/* One sentence: what `praisonai managed` does */}

{/* Hero Mermaid diagram — graph LR, standard color scheme (AGENTS.md §3.1) */}

## Quick Start
<Steps>
  <Step title="Authenticate">     # export ANTHROPIC_API_KEY=...
  <Step title="Create a session"> # praisonai managed sessions list  (shortest useful command)
  <Step title="Clean up">         # praisonai managed sessions delete <id> --yes
</Steps>

---

## How It Works
{/* sequenceDiagram: User → CLI → Anthropic API → Response, standard colors */}

---

## Commands

### Sessions
{/* Table of subcommands + one runnable example each. Cover: list, get, resume, delete */}

### Agents
{/* list, get, create, update, delete */}

### Environments
{/* list, get, update, delete  — show --packages and --networking clearly */}

### IDs helper
{/* save, restore, show — these are local, no Anthropic call */}

---

## Choosing a subcommand
{/* Decision-tree Mermaid diagram per AGENTS.md §6.1 — "if multiple options, show which to pick when" */}

---

## Safety: confirmation prompts
{/* Callout: all deletes prompt unless --yes; show the exact prompt string */}

---

## Authentication
{/* Explain ANTHROPIC_API_KEY → CLAUDE_API_KEY precedence and the `anthropic` pip dep */}

---

## Common Patterns
{/* 2–3 short shell snippets: cleanup loop, scripted env update, etc. */}

---

## Best Practices
<AccordionGroup>
  <Accordion title="Always script with --yes in CI">
  <Accordion title="Prefer `envs update --packages` over recreating envs">
  <Accordion title="Use `ids save` to checkpoint IDs you care about">
</AccordionGroup>

---

## Related
<CardGroup cols={2}>
  <Card href="/docs/features/managed-agent-persistence">ManagedAgent + DB persistence (Python SDK)</Card>
  <Card href="/docs/features/sessions">Sessions</Card>
</CardGroup>

Writing-style requirements (AGENTS.md §6)

  • Agent-centric and beginner-first. Someone who has never used the Anthropic managed infra should feel "this is just a few commands."
  • Each section starts with one sentence.
  • No forbidden phrases ("In this section…", "As you can see…", "Please note that…", "The following example shows…").
  • Every shell example must be copy-paste runnable; use realistic but fake IDs like sesn_01AbCdEf, agent_01AbCdEf, env_01AbCdEf (these are the exact examples in the docstrings).
  • Include a user-interaction flow showing the confirmation prompt in action (before/after --yes).

Mermaid diagrams (AGENTS.md §3)

At minimum:

  1. Hero graph LRUser → praisonai managed → Anthropic API → Resource (session/agent/env).
  2. sequenceDiagram — delete flow with confirmation branch (User / CLI / Anthropic), showing the --yes short-circuit.
  3. Decision graph TB — "Which subcommand do I want?" (list/get/create/update/delete across sessions/agents/envs).

Use the exact colour scheme from AGENTS.md §3.1 (#8B0000, #189AB4, #10B981, #F59E0B, #6366F1, white text, #7C90A0 strokes).

Acceptance checklist (for the implementing agent)

Content:

  • Read praisonai/cli/commands/managed.py completely before writing.
  • Read PR #1441 diff and the 22 destructive tests; every flag, help string, error message, and exit code in the page matches source.
  • Page covers all existing managed subcommands (sessions list/get/resume/delete, agents list/get/create/update/delete, envs list/get/update/delete, ids save/restore/show), not only the four added in #1441.
  • Authentication section mentions both ANTHROPIC_API_KEY and CLAUDE_API_KEY (precedence) and the pip install anthropic dependency.
  • Shows the exact confirmation prompt string and the exact cancellation output.
  • Documents the --networking allowed values (full, limited) and the --packages comma-separated / whitespace-trimmed behaviour.
  • Includes a "Nothing to update" example for envs update with no flags.

Structure (AGENTS.md §9):

  • Frontmatter: title, sidebarTitle, description, icon: "terminal".
  • Hero Mermaid diagram using the standard colour scheme.
  • <Steps> Quick Start, <AccordionGroup> Best Practices, <CardGroup cols={2}> Related.
  • No content placed in docs/concepts/ (violates AGENTS.md §1.8).
  • docs.json updated under Features group; JSON remains valid.
  • Cross-link to/from docs/features/managed-agent-persistence.mdx.

Quality:

  • One-sentence section intros; no forbidden phrases.
  • All examples are runnable as-is (no your-key-here placeholders).
  • White text on coloured Mermaid nodes; classDef declared.

References

/cc @MervinPraison

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclaudeTrigger Claude Code analysisdocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions