Skip to main content

Workflow Commands

Workflows allow you to chain multiple agents together, passing outputs from one agent as inputs to another. All workflow commands require a running daemon.
Workflow commands require the daemon to be running. Start it with:
openfang start

openfang workflow list

List all registered workflows.
openfang workflow list

Output

ID                                     NAME                    STEPS      CREATED
------------------------------------------------------------------------------------------
wf-a1b2c3d4-e5f6-...                  code-review-pipeline    3          2026-03-07 14:23:45
wf-b2c3d4e5-f6a7-...                  research-summarize      2          2026-03-07 15:10:22

Output Columns

  • ID: Workflow UUID
  • NAME: Workflow name from the definition
  • STEPS: Number of steps in the workflow
  • CREATED: Timestamp when the workflow was created

Example

openfang workflow list

openfang workflow create

Create a workflow from a JSON definition file.
openfang workflow create <FILE>

Arguments

ArgumentDescription
<FILE>Path to a JSON file describing the workflow steps.

Workflow Definition Format

Create a JSON file with the following structure:
workflow.json
{
  "name": "code-review-pipeline",
  "description": "Automated code review workflow",
  "steps": [
    {
      "name": "analyze",
      "agent": "coder",
      "prompt": "Analyze this code for bugs and security issues: {{input}}",
      "timeout": 30
    },
    {
      "name": "review",
      "agent": "security-auditor",
      "prompt": "Review this analysis and provide recommendations: {{analyze.output}}",
      "timeout": 60
    },
    {
      "name": "summarize",
      "agent": "writer",
      "prompt": "Create a summary report: {{review.output}}",
      "timeout": 30
    }
  ]
}

Step Fields

FieldRequiredDescription
nameYesStep identifier (used for referencing outputs)
agentYesAgent name or template to use
promptYesPrompt template (use {{input}} for workflow input, {{step.output}} for previous step outputs)
timeoutNoTimeout in seconds (default: 60)

Template Variables

  • {{input}} — The workflow’s initial input
  • {{step_name.output}} — Output from a previous step

Examples

openfang workflow create ./review-pipeline.json

Output

Workflow created successfully!
  ID:   wf-a1b2c3d4-e5f6-7890-abcd-ef1234567890
  Name: code-review-pipeline
  Steps: 3

openfang workflow run

Execute a workflow by ID.
openfang workflow run <WORKFLOW_ID> <INPUT>

Arguments

ArgumentDescription
<WORKFLOW_ID>Workflow UUID. Obtain from openfang workflow list.
<INPUT>Input text to pass to the workflow.

Behavior

  • Executes each step in sequence
  • Passes output from one step as input to the next (via template variables)
  • Displays progress and results for each step
  • Returns the final step’s output

Examples

openfang workflow run wf-a1b2c3d4 "Analyze this code for security issues: $(cat app.py)"

Example Output

Executing workflow: code-review-pipeline (3 steps)

[1/3] analyze (coder)
  Input: Analyze this code for bugs...
  [Running...]
  Output: Found 3 potential issues:
  1. SQL injection risk on line 42
  2. Missing input validation
  3. Unclosed file handle
  
  [tokens: 256 in / 148 out | 2.3s]

[2/3] review (security-auditor)
  Input: Review this analysis...
  [Running...]
  Output: Priority fixes:
  1. HIGH: SQL injection (line 42) - use parameterized queries
  2. MEDIUM: Input validation - add whitelist
  3. LOW: File handle - use context manager
  
  [tokens: 312 in / 201 out | 3.1s]

[3/3] summarize (writer)
  Input: Create a summary report...
  [Running...]
  Output: 
  ## Code Review Summary
  
  - **Critical**: Fix SQL injection vulnerability on line 42
  - **Recommended**: Add input validation for user data
  - **Minor**: Use context managers for file operations
  
  [tokens: 198 in / 89 out | 1.8s]

Workflow completed successfully!
Total time: 7.2s
Total tokens: 766 in / 438 out

Trigger Commands

Event triggers allow agents to react to system events (agent spawned, terminated, lifecycle changes, etc.).

openfang trigger list

List all event triggers.
openfang trigger list [--agent-id <ID>]

Options

OptionDescription
--agent-id <ID>Filter triggers by the owning agent’s UUID.

Output

TRIGGER ID                             AGENT ID         ENABLED    FIRES    PATTERN
----------------------------------------------------------------------------------------------------
tg-a1b2c3d4-...                       ag-b2c3d4e5...   true       10       {"agent_spawned":{...}}
tg-c3d4e5f6-...                       ag-b2c3d4e5...   true       0        {"lifecycle":{}}

Examples

# List all triggers
openfang trigger list

# List triggers for a specific agent
openfang trigger list --agent-id a1b2c3d4-e5f6-7890

openfang trigger create

Create an event trigger for an agent.
openfang trigger create <AGENT_ID> <PATTERN_JSON> [--prompt <TEMPLATE>] [--max-fires <N>]

Arguments

ArgumentDescription
<AGENT_ID>UUID of the agent that owns the trigger.
<PATTERN_JSON>Trigger pattern as a JSON string.

Options

OptionDefaultDescription
--prompt <TEMPLATE>"Event: {{event}}"Prompt template. Use {{event}} as a placeholder for the event data.
--max-fires <N>0 (unlimited)Maximum number of times the trigger will fire.

Pattern Examples

# Fire on any lifecycle event
openfang trigger create <AGENT_ID> '{"lifecycle":{}}'

Full Example

# Create a monitoring agent that logs when new agents spawn
openfang agent new assistant
# Copy the agent ID from output

openfang trigger create a1b2c3d4-e5f6 \
  '{"agent_spawned":{"name_pattern":"*"}}' \
  --prompt "Log this event: A new agent was spawned - {{event}}" \
  --max-fires 100

openfang trigger delete

Delete a trigger by ID.
openfang trigger delete <TRIGGER_ID>

Arguments

ArgumentDescription
<TRIGGER_ID>UUID of the trigger to delete.

Example

openfang trigger delete tg-a1b2c3d4-e5f6-7890

Complete Workflow Example

# 1. Ensure daemon is running
openfang start

# 2. Create a workflow definition
cat > review-pipeline.json <<'EOF'
{
  "name": "code-review-pipeline",
  "description": "Automated code review",
  "steps": [
    {
      "name": "analyze",
      "agent": "coder",
      "prompt": "Analyze this code: {{input}}"
    },
    {
      "name": "review",
      "agent": "security-auditor",
      "prompt": "Review: {{analyze.output}}"
    }
  ]
}
EOF

# 3. Create the workflow
openfang workflow create review-pipeline.json

# 4. List workflows to get the ID
openfang workflow list

# 5. Run the workflow
openfang workflow run wf-a1b2c3d4 "Review this code: $(cat app.py)"

Next Steps

Agent Commands

Spawn and manage agents

Skill Commands

Extend agent capabilities

Trigger API

Event triggers via REST API

CLI Overview

Back to CLI overview

Build docs developers (and LLMs) love