Skip to main content

Agents CLI

The PraisonAI TypeScript CLI provides commands for running multi-agent orchestration directly from the command line.

Commands Overview

# Run multiple agents
praisonai-ts agents run --config agents.yaml

# Run with inline definitions
praisonai-ts agents run --agents "researcher,writer" --task "Research and write about AI"

agents run

Run multiple agents in sequence or parallel.

Basic Usage

praisonai-ts agents run --config agents.yaml

With Inline Agents

praisonai-ts agents run \
  --agents "Researcher:Research the topic,Writer:Write based on research" \
  --task "AI trends in 2024"

Options

OptionDescriptionDefault
--config, -cPath to agents YAML config-
--agents, -aInline agent definitions (name:instructions)-
--task, -tTask to execute-
--process, -pProcess mode: sequential, parallelsequential
--model, -mLLM model for all agentsgpt-4o-mini
--verbose, -vEnable verbose outputtrue
--jsonOutput as JSONfalse

Examples

# Sequential pipeline
praisonai-ts agents run \
  --agents "Researcher:Research AI,Analyst:Analyze findings,Writer:Write report" \
  --task "AI market analysis" \
  --process sequential

# Parallel execution
praisonai-ts agents run \
  --agents "Analyst1:Analyze market A,Analyst2:Analyze market B" \
  --task "Compare markets" \
  --process parallel

# With config file
praisonai-ts agents run --config ./my-agents.yaml

# JSON output
praisonai-ts agents run \
  --agents "Agent1:Task 1,Agent2:Task 2" \
  --task "Complete workflow" \
  --json

Configuration File Format

agents.yaml

agents:
  - name: Researcher
    instructions: |
      You are a research specialist.
      Find accurate information on the given topic.
    model: gpt-4o-mini
    
  - name: Writer
    instructions: |
      You are a content writer.
      Write engaging content based on research.
    model: gpt-4o-mini

process: sequential
verbose: true

With Tasks

agents:
  - name: Researcher
    instructions: Research the topic
  - name: Writer
    instructions: Write based on research

tasks:
  - Research AI developments in 2024
  - Write a 500-word summary

process: sequential

With Tools

agents:
  - name: WebResearcher
    instructions: Search the web for information
    tools:
      - web_search
      - read_url
      
  - name: DataAnalyst
    instructions: Analyze the collected data
    tools:
      - analyze_data

JSON Output Format

{
  "success": true,
  "data": {
    "results": [
      {
        "agent": "Researcher",
        "output": "Research findings..."
      },
      {
        "agent": "Writer",
        "output": "Written article..."
      }
    ],
    "process": "sequential",
    "agentCount": 2
  },
  "meta": {
    "duration_ms": 5432,
    "model": "gpt-4o-mini"
  }
}

Process Modes

Sequential

Agents run one after another. Each agent receives the previous agent’s output:
praisonai-ts agents run \
  --agents "Step1:First task,Step2:Second task,Step3:Third task" \
  --process sequential
Output flow:
Step1 → output → Step2 → output → Step3 → final output

Parallel

All agents run simultaneously:
praisonai-ts agents run \
  --agents "Worker1:Task A,Worker2:Task B,Worker3:Task C" \
  --process parallel
Output flow:
Worker1 → output1
Worker2 → output2  (all run at same time)
Worker3 → output3

Environment Variables

# API Keys
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...

# Default model
export PRAISONAI_MODEL=gpt-4o-mini

# Behavior
export PRAISON_VERBOSE=true

Scripting Examples

Bash Pipeline

#!/bin/bash

# Run agents and process results
RESULT=$(praisonai-ts agents run \
  --agents "Researcher:Find data,Analyst:Analyze data" \
  --task "Market analysis" \
  --json)

# Extract specific agent output
RESEARCH=$(echo $RESULT | jq -r '.data.results[0].output')
ANALYSIS=$(echo $RESULT | jq -r '.data.results[1].output')

echo "Research: $RESEARCH"
echo "Analysis: $ANALYSIS"

Error Handling

#!/bin/bash

if ! praisonai-ts agents run --config agents.yaml; then
  echo "Agent execution failed"
  exit 1
fi

Common Patterns

Research → Write Pipeline

praisonai-ts agents run \
  --agents "Researcher:Research thoroughly,Writer:Write engaging content" \
  --task "Write about quantum computing"

Multi-Perspective Analysis

praisonai-ts agents run \
  --agents "Optimist:Find positives,Pessimist:Find risks,Analyst:Balance views" \
  --task "Analyze the new product launch" \
  --process sequential

Parallel Data Collection

praisonai-ts agents run \
  --agents "NewsAgent:Get news,SocialAgent:Get social trends,DataAgent:Get statistics" \
  --task "Gather information about AI" \
  --process parallel

See Also