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.
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.
Quick Start
- Set API Key
Export your Anthropic API key:
bash export ANTHROPIC_API_KEY=sk-ant-... - List Sessions
View sessions for an agent:
bash praisonai managed sessions list agent_01AbCdEf - Delete with Confirmation
Clean up resources safely:
bash praisonai managed sessions delete sesn_01AbCdEf --yes
How It Works
Commands
Sessions
Manage Anthropic-hosted agent sessions:
| Command | Purpose | Example |
|---|---|---|
sessions list <agent_id> | List sessions for an agent | praisonai managed sessions list agent_01AbCdEf |
sessions get <session_id> | Get session details and usage | praisonai managed sessions get sesn_01AbCdEf |
sessions resume <session_id> "<prompt>" | Resume session with new prompt | praisonai managed sessions resume sesn_01AbCdEf "Continue the task" |
sessions delete <session_id> | Delete a session (with confirmation) | praisonai managed sessions delete sesn_01AbCdEf --yes |
# 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 --yesAgents
Manage your Anthropic-hosted agents:
| Command | Purpose | Example |
|---|---|---|
agents list | List all your agents | praisonai managed agents list |
agents get <agent_id> | Get agent configuration | praisonai managed agents get agent_01AbCdEf |
agents create | Create new agent (via Python SDK) | See HostedAgent docs |
agents update <agent_id> | Update agent name, system, or model | praisonai 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 |
# 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 --yesEnvironments
Manage sandbox environments for code execution:
| Command | Purpose | Example |
|---|---|---|
envs list | List your environments | praisonai managed envs list |
envs get <env_id> | Get environment details | praisonai managed envs get env_01AbCdEf |
envs update <env_id> | Update packages or networking | praisonai 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 |
# 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 --yesEnvironment Update Options:
--packages: Comma-separated pip packages (whitespace is trimmed, empty entries filtered)--networking: Eitherfullorlimited(case-sensitive)
Sandbox Lifecycle: ps / stop
List and reclaim running agent sandboxes across every provider.
| Command | Purpose | Example |
|---|---|---|
managed ps | List every running agent sandbox across all providers | praisonai managed ps |
managed ps --json | Machine-readable output ({"sandboxes": [...], "errors": [...]}) | praisonai managed ps --json |
managed ps --provider docker (or -p) | Filter to one provider | praisonai managed ps -p docker |
managed stop <instance-id> | Reclaim one sandbox by ID | praisonai managed stop docker_a1b2c3d4 |
managed stop --all | Reclaim every running sandbox (across providers) | praisonai managed stop --all |
managed stop --all --provider docker | Reclaim every sandbox from one provider | praisonai 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.
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 foofor 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, sops/stopnever report a clean sweep when some providers could not be queried. - Docker containers are discovered cross-process via the
praisonai=managedlabel andpraisonai_<id>naming convention, so containers started by an earlier CLI or a crashed script are still visible from a fresh CLI invocation. psandstopscandocker,e2b,modal,daytona,flyio, andtenki.localis excluded — it runs on this machine, so there is nothing to reclaim.- Uptime is formatted as
Nsunder a minute,Nmunder an hour,NhMMmunder a day, andNdHHhbeyond that.
IDs Helper
Save and restore Anthropic-assigned resource IDs locally:
| Command | Purpose | Example |
|---|---|---|
ids save <agent_id> <env_id> <session_id> | Save IDs to JSON file | praisonai managed ids save agent_01... env_01... sesn_01... --version 1 |
ids restore "<prompt>" | Restore IDs and run prompt | praisonai managed ids restore "Continue previous task" |
ids show | Display saved IDs | praisonai managed ids show |
# 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
Safety: Confirmation Prompts
Authentication
The CLI requires the anthropic Python package and one of these environment variables:
# Primary (checked first)
export ANTHROPIC_API_KEY=sk-ant-api-...
# Fallback
export CLAUDE_API_KEY=sk-ant-api-...Installation:
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:
#!/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
doneEnvironment Setup
Install packages and configure networking:
# 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_IDSession Backup
Save session state before major changes:
# 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).jsonRecover Stray Sandboxes
Find sandboxes left behind by a crashed run and reclaim them:
# 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 --allBest Practices
Resource Management
- Use
--yesin 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
--limitto prevent large resource listings
Environment Updates
- Test package installations in development environments first
- Use
--networking limitedfor security-sensitive workloads - Keep package lists minimal to reduce startup time
- Update packages gradually to identify compatibility issues
Session Continuity
- Use
sessions resumeinstead of creating new sessions - Save session IDs for important conversations
- Monitor session usage with
sessions get - Implement session rotation for long-running applications