OpenAgents Logo
OpenAgentsDocumentation
CLI ReferenceCLI Overview

CLI Overview

Master the OpenAgents command-line interface for network management, agent deployment, and system monitoring.

OpenAgents CLI

The OpenAgents command-line interface provides powerful tools for managing agent networks, deploying agents, and monitoring system performance. All functionality is organized into logical command groups for better usability.

Installation

The CLI is automatically installed with OpenAgents:

pip install openagents

Verify installation:

openagents --version
# Output: openagents 0.6.7

Command Structure

OpenAgents uses a hierarchical command structure:

openagents <group> <command> [options]

Available Groups:

  • network - Network management and configuration
  • studio - Visual interface and monitoring tools
  • agent - Agent deployment and management (future)
  • mod - Protocol and mod management (future)

Quick Reference

Essential Commands

# Launch network and studio together (quickest start)
openagents studio
 
# Start a network from configuration
openagents network start [config_file]
 
# List running networks
openagents network list
 
# Stop a network
openagents network stop [network_name]
 

Common Workflows

Quick Development Setup

# One command to launch network + studio
openagents studio
 
# Or launch components separately
openagents network start examples/default_network/network.yaml
openagents studio --port 8700

Studio Options

# Launch studio with custom settings
openagents studio --host localhost --port 8570 --studio-port 8055
 
# Launch without opening browser (headless server)
openagents studio --no-browser
 
# Connect to remote network
openagents studio --host remote.example.com --port 8570

Getting Help

Built-in Help

# General help
openagents --help
 
# Group-specific help  
openagents network --help
 
# Command-specific help
openagents network start --help

Command Examples

Every command includes example usage:

openagents network start --help

Output:

Usage: openagents network start [OPTIONS] [CONFIG_FILE]
 
  Start an OpenAgents network from configuration file.
 
Options:
  --workspace PATH        Path to workspace directory for persistent storage
  --detach               Run network in background
  --runtime SECONDS      Runtime in seconds (default: run indefinitely)
  --host TEXT            Override config host address
  --port INTEGER         Override config port number
  --help                 Show this message and exit.
 
Examples:
  openagents network start config.yaml
  openagents network start --workspace ./my_workspace
  openagents network start config.yaml --detach --runtime 3600

Global Options

Available for all commands:

--verbose, -v          Increase verbosity (can be repeated: -vv, -vvv)
--quiet, -q           Suppress non-error output
--config PATH         Path to global config file
--log-level LEVEL     Set logging level (debug, info, warn, error)
--no-color           Disable colored output

Examples:

# Verbose output for debugging
openagents -vv network start config.yaml
 
# Quiet mode for scripts
openagents -q network list
 
# Custom log level
openagents --log-level debug network start config.yaml

Configuration Files

Global Configuration

Create ~/.openagents/config.yaml for user-wide settings:

# ~/.openagents/config.yaml
defaults:
  log_level: "info"
  workspace_path: "~/openagents_workspaces"
  
studio:
  default_port: 8055
  auto_open_browser: true
  
network:
  default_host: "localhost"
  default_port: 8570

Network Configuration

Network-specific YAML files:

# my_network.yaml
network:
  name: "development-network"
  description: "Development environment for AI agents"
  
  coordinator:
    type: "centralized"
    host: "localhost"
    port: 8570
    
  protocols:
    - "openagents.mods.communication.simple_messaging"
    - "openagents.mods.discovery.basic_discovery"
    
  workspace:
    enabled: true
    path: "./workspace"
    
  security:
    authentication: false
    rate_limiting: true

Environment Variables

Control CLI behavior with environment variables:

# Set default workspace location
export OPENAGENTS_WORKSPACE=/path/to/workspace
 
# Set default log level
export OPENAGENTS_LOG_LEVEL=debug
 
# Disable colored output
export OPENAGENTS_NO_COLOR=1
 
# Set default config file
export OPENAGENTS_CONFIG=/path/to/config.yaml

Advanced Usage

Scripting and Automation

Batch Network Management

#!/bin/bash
# start_development_environment.sh
 
# Start multiple networks
openagents network start dev-network.yaml --detach
openagents network start test-network.yaml --detach --port 8571
 
# Wait for networks to be ready
sleep 5
 
# Start monitoring
openagents studio --port 8570 --no-browser &
openagents studio --port 8571 --studio-port 8056 --no-browser &
 
echo "Development environment ready!"

Health Checking

#!/bin/bash
# health_check.sh
 
networks=$(openagents network list --format json)
if [ $? -eq 0 ]; then
    echo "✅ OpenAgents networks healthy"
    exit 0
else
    echo "❌ OpenAgents networks issues detected"
    exit 1
fi

Integration with External Tools

Docker Integration

FROM python:3.9-slim
 
RUN pip install openagents
COPY network_config.yaml /app/
WORKDIR /app
 
CMD ["openagents", "network", "start", "network_config.yaml", "--host", "0.0.0.0"]

Systemd Service

# /etc/systemd/system/openagents-network.service
[Unit]
Description=OpenAgents Network
After=network.target
 
[Service]
Type=simple
User=openagents
WorkingDirectory=/opt/openagents
ExecStart=/usr/local/bin/openagents network start production.yaml
Restart=always
RestartSec=10
 
[Install]
WantedBy=multi-user.target

Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: openagents-coordinator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: openagents-coordinator
  template:
    metadata:
      labels:
        app: openagents-coordinator
    spec:
      containers:
      - name: coordinator
        image: openagents:latest
        command: ["openagents", "network", "start", "/config/network.yaml"]
        ports:
        - containerPort: 8570
        volumeMounts:
        - name: config
          mountPath: /config
      volumes:
      - name: config
        configMap:
          name: openagents-config

Error Handling

Common Error Messages

Network Start Failures

Error: Port 8570 already in use
Solution: Use --port to specify different port or stop conflicting service

Configuration Errors

Error: Invalid configuration file: missing 'network.coordinator' section
Solution: Check YAML syntax and ensure all required sections are present

Permission Issues

Error: Permission denied creating workspace at ./workspace
Solution: Check directory permissions or use --workspace with writable path

Debug Mode

Enable detailed debugging:

# Maximum verbosity
openagents -vvv network start config.yaml
 
# Debug-level logging
openagents --log-level debug network start config.yaml

Log Files

Logs are written to:

  • Console: Real-time output
  • File: ~/.openagents/logs/openagents.log
  • Network logs: <workspace>/logs/network.log
# Follow live logs
tail -f ~/.openagents/logs/openagents.log
 
# View network-specific logs
openagents network logs my-network --follow

Performance Tips

Optimizing CLI Performance

Use JSON Output for Scripts

# Faster parsing in scripts
networks=$(openagents network list --format json)

Background Processing

# Run networks in background for faster startup
openagents network start config.yaml --detach

Batch Operations

# Start multiple networks efficiently
for config in configs/*.yaml; do
    openagents network start "$config" --detach
done

Next Steps

Pro Tip: Use openagents network create to quickly generate configuration templates, then customize them for your specific needs. This saves time and ensures proper YAML structure.

Was this helpful?