Managed CLI

List and reclaim managed sandboxes, and manage Anthropic-hosted sessions, agents, and environments from the terminal

The praisonai managed command group lists and reclaims managed sandboxes across every provider (docker, e2b, modal, daytona, flyio, tenki) and manages Anthropic-hosted sessions, agents, and environments from the terminal.

python
from praisonaiagents import Agent

agent = Agent(name="managed-agent", instructions="Use managed CLI commands for automation.")
agent.start("Run the managed deploy command for production.")

The user runs praisonai managed commands to create, inspect, and tear down hosted agents and sessions from the terminal.

Diagram

Managed CLI

👤 User

⚡ praisonai managed

☁️ Anthropic API

🐳 Local + cloud sandboxes
docker / e2b / modal / …

📋 Session / Agent / Env

📦 Sandbox instance

Quick Start

  1. Set API Key

    Export your Anthropic API key:

    bash
    export ANTHROPIC_API_KEY=sk-ant-...
  2. List Sessions

    View sessions for an agent:

    bash
    praisonai managed sessions list agent_01AbCdEf
  3. Delete with Confirmation

    Clean up resources safely:

    bash
    praisonai managed sessions delete sesn_01AbCdEf --yes

How It Works

Diagram
ResponseAnthropicCLIUserResponseAnthropicCLIUser–yes flag skips confirmationpraisonai managed sessions delete sesn_01AbCdEfAre you sure you want to delete sesn_01AbCdEf?yAPI delete requestSuccess responseDeleted successfully

Commands

Sessions

Manage Anthropic-hosted agent sessions:

CommandPurposeExample
sessions list <agent_id>List sessions for an agentpraisonai managed sessions list agent_01AbCdEf
sessions get <session_id>Get session details and usagepraisonai managed sessions get sesn_01AbCdEf
sessions resume <session_id> "<prompt>"Resume session with new promptpraisonai managed sessions resume sesn_01AbCdEf "Continue the task"
sessions delete <session_id>Delete a session (with confirmation)praisonai managed sessions delete sesn_01AbCdEf --yes
bash
# List recent sessions
praisonai managed sessions list agent_01AbCdEf --limit 5

# Get detailed session info
praisonai managed sessions get sesn_01AbCdEf

# Resume previous conversation
praisonai managed sessions resume sesn_01AbCdEf "What did we discuss?"

# Clean up old sessions
praisonai managed sessions delete sesn_01AbCdEf --yes

Agents

Manage your Anthropic-hosted agents:

CommandPurposeExample
agents listList all your agentspraisonai managed agents list
agents get <agent_id>Get agent configurationpraisonai managed agents get agent_01AbCdEf
agents createCreate new agent (via Python SDK)See HostedAgent docs
agents update <agent_id>Update agent name, system, or modelpraisonai managed agents update agent_01AbCdEf --name "New Name" --version 1
agents delete <agent_id>Delete an agent (with confirmation)praisonai managed agents delete agent_01AbCdEf --yes
bash
# List your agents
praisonai managed agents list

# View agent details
praisonai managed agents get agent_01AbCdEf

# Update agent configuration  
praisonai managed agents update agent_01AbCdEf --system "You are a data analyst." --version 2

# Remove unused agent
praisonai managed agents delete agent_01AbCdEf --yes

Environments

Manage sandbox environments for code execution:

CommandPurposeExample
envs listList your environmentspraisonai managed envs list
envs get <env_id>Get environment detailspraisonai managed envs get env_01AbCdEf
envs update <env_id>Update packages or networkingpraisonai managed envs update env_01AbCdEf --packages "pandas,numpy" --networking full
envs delete <env_id>Delete an environment (with confirmation)praisonai managed envs delete env_01AbCdEf --yes
bash
# List environments
praisonai managed envs list

# Install packages
praisonai managed envs update env_01AbCdEf --packages "requests,beautifulsoup4"

# Change networking mode
praisonai managed envs update env_01AbCdEf --networking limited

# Clean up environment
praisonai managed envs delete env_01AbCdEf --yes

Environment Update Options:

  • --packages: Comma-separated pip packages (whitespace is trimmed, empty entries filtered)
  • --networking: Either full or limited (case-sensitive)

Sandbox Lifecycle: ps / stop

List and reclaim running agent sandboxes across every provider.

CommandPurposeExample
managed psList every running agent sandbox across all providerspraisonai managed ps
managed ps --jsonMachine-readable output ({"sandboxes": [...], "errors": [...]})praisonai managed ps --json
managed ps --provider docker (or -p)Filter to one providerpraisonai managed ps -p docker
managed stop <instance-id>Reclaim one sandbox by IDpraisonai managed stop docker_a1b2c3d4
managed stop --allReclaim every running sandbox (across providers)praisonai managed stop --all
managed stop --all --provider dockerReclaim every sandbox from one providerpraisonai managed stop --all -p docker

Sandboxes normally self-destruct when a run ends. A crashed or killed run leaves one behind, and ps / stop are the way to see and reclaim it.

text
INSTANCE ID                PROVIDER   STATUS     UPTIME   IMAGE
------------------------------------------------------------------------------
docker_5afaa3bfa704        docker     running    42s      python:3.12-slim

1 running. Stop with: praisonai managed stop <instance-id>

Behaviour:

  • Providers that are not installed or not configured (no E2B key, Docker daemon down, etc.) are skipped silently — absence of credentials is a normal state, not an error.
  • An explicit --provider foo for an uninstalled or unknown provider is surfaced as an error (exit code 1) — you asked for it, so silence would mislead.
  • Available providers whose lookup fails are surfaced under errors: in the JSON output and printed at the bottom of the text output; the exit code is 1 in that case, so ps / stop never report a clean sweep when some providers could not be queried.
  • Docker containers are discovered cross-process via the praisonai=managed label and praisonai_<id> naming convention, so containers started by an earlier CLI or a crashed script are still visible from a fresh CLI invocation.
  • ps and stop scan docker, e2b, modal, daytona, flyio, and tenki. local is excluded — it runs on this machine, so there is nothing to reclaim.
  • Uptime is formatted as Ns under a minute, Nm under an hour, NhMMm under a day, and NdHHh beyond that.

IDs Helper

Save and restore Anthropic-assigned resource IDs locally:

CommandPurposeExample
ids save <agent_id> <env_id> <session_id>Save IDs to JSON filepraisonai managed ids save agent_01... env_01... sesn_01... --version 1
ids restore "<prompt>"Restore IDs and run promptpraisonai managed ids restore "Continue previous task"
ids showDisplay saved IDspraisonai managed ids show
bash
# Save current resource IDs
praisonai managed ids save agent_01AbCdEf env_01AbCdEf sesn_01AbCdEf --version 1

# View saved IDs
praisonai managed ids show

# Resume with saved state
praisonai managed ids restore "What was I working on?"

Choosing a Subcommand

Diagram

Which resource?

Sessions

Agents

Environments

Sandboxes

ID Management

list – View agent sessions

get – Session details

resume – Continue conversation

delete – Remove session

list – View your agents

get – Agent details

update – Modify agent

delete – Remove agent

list – View environments

get – Environment details

update – Install packages/change networking

delete – Remove environment

ps – List running sandboxes

stop – Reclaim a sandbox

save – Store IDs locally

show – View saved IDs

restore – Resume with saved IDs


Safety: Confirmation Prompts


Authentication

The CLI requires the anthropic Python package and one of these environment variables:

bash
# Primary (checked first)
export ANTHROPIC_API_KEY=sk-ant-api-...

# Fallback
export CLAUDE_API_KEY=sk-ant-api-...

Installation:

bash
pip install 'anthropic>=0.94.0'

Without the package or API key, commands exit with code 1 and an error message.


Common Patterns

Cleanup Script

Remove old sessions and unused resources:

bash
#!/bin/bash
# cleanup-resources.sh

AGENT_ID="agent_01AbCdEf"

# List and delete old sessions
echo "Cleaning sessions for $AGENT_ID..."
praisonai managed sessions list $AGENT_ID --limit 20 | tail -n +3 | while read id status title; do
  if [[ $status == "completed" ]]; then
    praisonai managed sessions delete $id --yes
    echo "Deleted session: $id"
  fi
done

# List and delete unused environments  
echo "Cleaning environments..."
praisonai managed envs list | tail -n +3 | while read id status name; do
  if [[ $status == "inactive" ]]; then
    praisonai managed envs delete $id --yes
    echo "Deleted environment: $id"
  fi
done

Environment Setup

Install packages and configure networking:

bash
# Update development environment
ENV_ID="env_01AbCdEf"
praisonai managed envs update $ENV_ID \
  --packages "pandas,numpy,matplotlib,jupyter" \
  --networking full

# Verify installation
praisonai managed envs get $ENV_ID

Session Backup

Save session state before major changes:

bash
# Backup current session state
praisonai managed ids save agent_01AbCdEf env_01AbCdEf sesn_01AbCdEf \
  --version 1 --file backup-$(date +%Y%m%d).json

# Show what was backed up
praisonai managed ids show --file backup-$(date +%Y%m%d).json

Recover Stray Sandboxes

Find sandboxes left behind by a crashed run and reclaim them:

bash
# See what is still running
praisonai managed ps

# Reclaim one by ID
praisonai managed stop docker_5afaa3bfa704

# Or reclaim everything at once
praisonai managed stop --all

Best Practices

Resource Management
  • Use --yes in scripts to avoid interactive prompts
  • Regularly clean up completed sessions to manage costs
  • Save important session IDs before deleting resources
  • Monitor environment status before making updates
Error Handling
  • Check exit codes in scripts (0 = success, 1 = error)
  • Handle API timeouts with retry logic
  • Verify API key is set before running commands
  • Use --limit to prevent large resource listings
Environment Updates
  • Test package installations in development environments first
  • Use --networking limited for security-sensitive workloads
  • Keep package lists minimal to reduce startup time
  • Update packages gradually to identify compatibility issues
Session Continuity
  • Use sessions resume instead of creating new sessions
  • Save session IDs for important conversations
  • Monitor session usage with sessions get
  • Implement session rotation for long-running applications

Related