Skip to content

Task Chains

A task chain is a JSON state machine that defines how the AI agent behaves end-to-end. Chains are composable, inspectable, and backend-agnostic.

Task Chain Execution Flow

Chain structure

json
{
  "id": "my-chain",
  "description": "What this chain does",
  "tasks": [ /* TaskDefinition[] */ ],
  "token_limit": 8192,
  "debug": false
}
FieldTypeDescription
idstringUnique identifier
descriptionstringHuman-readable description
tasksTaskDefinition[]Ordered list of task definitions
token_limitintMax token budget for the chat history
debugboolEnable verbose task-level logging

Task structure

json
{
  "id": "step_name",
  "handler": "chat_completion",
  "system_instruction": "...",
  "execute_config": { },
  "transition": { "branches": [ ] },
  "retry_on_failure": 0,
  "timeout": "30s"
}

See Handlers and Transitions for the full field reference.

Sections

Released under the Apache 2.0 License.