Skip to main content
The Workflow API enables you to create and execute multi-step agent workflows with support for sequential, parallel, conditional, and loop execution modes.

Workflow Concepts

Workflows in AgentOS support five execution modes:
  • Sequential: Steps execute one after another, with output passed to the next step
  • Fanout: Multiple steps execute in parallel
  • Collect: Aggregates results from fanout steps
  • Conditional: Step executes only if a condition is met
  • Loop: Repeats a step until a condition is met or max iterations reached

List Workflows

Get all registered workflows.
GET /api/workflows

Response

workflows
array
Array of workflow objects with their configurations.

Example

curl -X GET http://localhost:3111/api/workflows \
  -H "Authorization: Bearer YOUR_API_KEY"

Create Workflow

Register a new workflow definition.
POST /api/workflows

Request

id
string
Optional workflow ID. Auto-generated if not provided.
name
string
required
The name of the workflow.
description
string
required
Description of what the workflow does.
steps
array
required
Array of workflow step objects.

Response

id
string
The unique identifier for the created workflow.

Example

curl -X POST http://localhost:3111/api/workflows \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "research-and-summarize",
    "description": "Research a topic and create a summary",
    "steps": [
      {
        "name": "research",
        "functionId": "tools::web_search",
        "mode": "sequential",
        "promptTemplate": "{{input}}",
        "timeoutMs": 30000,
        "errorMode": "retry",
        "maxRetries": 3,
        "outputVar": "searchResults"
      },
      {
        "name": "summarize",
        "functionId": "agent::chat",
        "mode": "sequential",
        "promptTemplate": "Summarize these search results: {{searchResults}}",
        "timeoutMs": 60000,
        "errorMode": "fail"
      }
    ]
  }'

Run Workflow

Execute a workflow with input data.
POST /api/workflows/run

Request

workflowId
string
required
The ID of the workflow to execute.
input
any
required
Input data to pass to the workflow. Available as {{input}} in step templates.
agentId
string
Optional agent ID for capability checks on workflow steps.

Response

runId
string
Unique identifier for this workflow run.
results
array
Array of step results.
vars
object
Final state of all workflow variables.

Example

curl -X POST http://localhost:3111/api/workflows/run \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflowId": "wf-123",
    "input": "Latest developments in quantum computing",
    "agentId": "agent-456"
  }'

Response Example

{
  "runId": "run-a1b2c3d4",
  "results": [
    {
      "stepName": "research",
      "output": {
        "results": [
          {"title": "Quantum Computing Breakthrough", "url": "..."}
        ]
      },
      "durationMs": 1250
    },
    {
      "stepName": "summarize",
      "output": "Recent quantum computing advances include...",
      "durationMs": 3420
    }
  ],
  "vars": {
    "input": "Recent quantum computing advances include...",
    "searchResults": {"results": [...]}
  }
}

Get Workflow Runs

Retrieve execution history for a workflow.
GET /api/workflows/:id/runs

Path Parameters

id
string
required
The workflow ID.

Query Parameters

limit
number
default:50
Maximum number of runs to return (1-100).
offset
number
default:0
Number of runs to skip for pagination.

Response

runs
array
Array of workflow run objects.
total
number
Total number of runs for this workflow.
limit
number
The limit used for this request.
offset
number
The offset used for this request.

Advanced Workflow Examples

Parallel Processing with Fanout/Collect

{
  "name": "multi-source-research",
  "description": "Search multiple sources in parallel",
  "steps": [
    {
      "name": "search-web",
      "functionId": "tools::web_search",
      "mode": "fanout",
      "promptTemplate": "{{input}}",
      "timeoutMs": 30000,
      "outputVar": "webResults"
    },
    {
      "name": "search-academic",
      "functionId": "tools::academic_search",
      "mode": "fanout",
      "promptTemplate": "{{input}}",
      "timeoutMs": 30000,
      "outputVar": "academicResults"
    },
    {
      "name": "merge-results",
      "functionId": "agent::chat",
      "mode": "collect",
      "promptTemplate": "Merge these research results: {{__fanout}}",
      "timeoutMs": 60000
    }
  ]
}

Conditional Execution

{
  "name": "conditional-analysis",
  "description": "Perform deep analysis only if initial check warrants it",
  "steps": [
    {
      "name": "initial-check",
      "functionId": "agent::chat",
      "mode": "sequential",
      "promptTemplate": "Quick check: {{input}}",
      "outputVar": "checkResult"
    },
    {
      "name": "deep-analysis",
      "functionId": "agent::chat",
      "mode": "conditional",
      "condition": "needs analysis",
      "promptTemplate": "Perform deep analysis on: {{input}}",
      "timeoutMs": 120000
    }
  ]
}

Loop Until Condition

{
  "name": "iterative-refinement",
  "description": "Refine output until quality threshold is met",
  "steps": [
    {
      "name": "refine",
      "functionId": "agent::chat",
      "mode": "loop",
      "promptTemplate": "Refine this text: {{input}}",
      "maxIterations": 5,
      "until": "quality: excellent",
      "timeoutMs": 60000
    }
  ]
}

Error Handling

Workflow steps support three error modes:
  • fail: Stop workflow execution and return error (default)
  • skip: Skip the failed step and continue
  • retry: Retry the step up to maxRetries times before failing
Failed workflow runs store:
  • Run status: "failed"
  • Error message
  • Results from successfully completed steps
  • Timestamp of failure

Rate Limiting

  • List workflows: 200 requests/hour
  • Create workflow: 100 requests/hour
  • Run workflow: 100 requests/hour

Security

When agentId is provided in workflow run requests, the system:
  1. Checks RBAC capabilities for each step’s function
  2. Enforces tool policies
  3. Validates against the agent’s allowed capabilities
  4. Records execution in audit log
This ensures workflows respect agent-level security constraints.

Build docs developers (and LLMs) love