Skip to main content
The praisonai managed command group provides terminal-based management of Anthropic-hosted sessions, agents, and environments.
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

1

Set API Key

Export your Anthropic API key:
export ANTHROPIC_API_KEY=sk-ant-...
2

List Sessions

View sessions for an agent:
praisonai managed sessions list agent_01AbCdEf
3

Delete with Confirmation

Clean up resources safely:
praisonai managed sessions delete sesn_01AbCdEf --yes

How It Works


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
# 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
# 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
# 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)

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
# 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

All delete commands prompt for confirmation unless --yes is provided:
# Shows prompt: "Are you sure you want to delete sesn_01AbCdEf?"
praisonai managed sessions delete sesn_01AbCdEf

# Skips prompt
praisonai managed sessions delete sesn_01AbCdEf --yes
Typing anything non-affirmative prints Deletion cancelled. and exits with code 0.

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
done

Environment 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_ID

Session 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).json

Best Practices

  • 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
  • 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
  • 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
  • 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

Hosted Agent

Python SDK for Anthropic-hosted agents

HostedAgent + DB persistence

Library-level persistence with database backends

Sessions

Advanced session management concepts