Skip to main content
The Corti Agent SDK is in alpha v2 private preview. The API may change between releases. Contact help@corti.ai to request access.
The Agent SDK provides three composition primitives for coordinating multiple agents. Start with workflow; only reach for stateGraph when you need cycles or branching that depends on accumulated state.

At a glance

The three patterns differ in topology:
Each step runs in order. A when predicate can skip a step, and transform can rewrite the input to the next step.
All agents run at the same time on the same input. Fulfilled results are collected; rejected steps are isolated.
Nodes share a typed state object. Routing functions inspect the state after each node and pick the next node, END, or loop back. maxIterations bounds cycles.

Workflow

A Workflow is a fixed list of steps. Each step receives the previous step’s response (or a transform of it) and returns a new response.

Step options

Each step can be a bare AgentHandle, a Parallel group (auto-wrapped), or a configuration object:

WorkflowResult

Parallel

Parallel runs multiple agents concurrently on the same input. Use it standalone or drop it into a workflow step list.

Per-step overrides

Pass per-step input or credentials when branches need different data:

ParallelResult

Parallel swallows individual failures. Inspect rejected if you need fail-fast semantics. When used inside a Workflow, if all parallel steps fail, the workflow throws.

StateGraph

When you need cycles or branching that depends on accumulated state, use StateGraph<TState>. Each node mutates a typed state object; edges route to the next node, including loops bounded by maxIterations.

Concepts

  • State: a plain typed object that accumulates across every node execution. Each node returns a Partial<S> that is shallow-merged in.
  • Nodes: async functions (state: S) => Promise<Partial<S>>. Use agentNode() to wrap an AgentHandle.
  • Edges: a static node name, END, or a routing function (state: S) => string | END that runs after the node updates the state.
  • END: sentinel that stops execution. A node with no registered edge also terminates the run.

Minimal example

agentNode

Wraps an AgentHandle as a node function. Provide two callbacks: one to extract the agent’s input from state, and one to merge the response back.

Custom nodes

You can add non-agent nodes that transform state directly:

Result shape

Choosing between workflow and stateGraph

Decision guide