Agents CLI

Command-line interface for multi-agent orchestration

The PraisonAI TypeScript CLI runs multi-agent orchestration directly from the terminal.

Diagram

User

CLI

AgentTeam

Results

Quick Start

  1. Simple Usage
    bash
    praisonai-ts agents run "Research and summarise AI news"
  2. With Configuration
    bash
    praisonai-ts agents run "Research and write about AI" \
      --agents "Research the topic,Write based on research" \
      --process parallel

Commands Overview

bash
# Run the default Researcher → Writer pair
praisonai-ts agents run "Research and write about AI"

# Run with inline agent instructions
praisonai-ts agents run "Research and write about AI" --agents "Research the topic,Write based on research"

agents run

Run multiple agents in sequence or parallel.

Basic Usage

With no --agents, a Researcher and a Writer agent run the task.

bash
praisonai-ts agents run "AI trends in 2024"

With Inline Agents

bash
praisonai-ts agents run "AI trends in 2024" \
  --agents "Research the topic,Write based on research"

Options

OptionDescriptionDefault
<task>Task to execute (positional, required)–
--agentsComma-separated agent instructions (agents are named Agent_1, Agent_2, …)Researcher + Writer
--processProcess mode: sequential, parallelsequential
--model, -mLLM model for all agentsProvider default
--verbose, -vEnable verbose outputfalse
--jsonOutput as JSONfalse

Examples

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

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

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

YAML Workflows

agents run takes agents inline only. To run agents defined in a YAML file, use the workflow command:

bash
praisonai-ts workflow workflow.yaml

JSON Output Format

json
{
  "success": true,
  "data": {
    "results": [
      "Research findings...",
      "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:

bash
praisonai-ts agents run "Plan a product launch" \
  --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:

bash
praisonai-ts agents run "Summarise three markets" \
  --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

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

bash
#!/bin/bash

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

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

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

Error Handling

bash
#!/bin/bash

if ! praisonai-ts agents run "Market analysis"; then
  echo "Agent execution failed"
  exit 1
fi

Common Patterns

Research → Write Pipeline

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

Multi-Perspective Analysis

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

Parallel Data Collection

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

Related