Skip to content

Sequential agent

A sequential agent runs an ordered list of sub-agents one at a time, piping each one's output into the next one's input. The whole pipeline returns the last sub-agent's response. Pick this when the work decomposes into a fixed pipeline — extract → reason → format, research → outline → draft → review — and you want each stage to be its own agent with its own model / prompt / tools.

Type identifier

YAML form:

agents:
  - id: ingest-pipeline
    type: sequential
    sub_agents:
      - { id: extract,  type: react, ... }
      - { id: reason,   type: react, ... }
      - { id: format,   type: react, ... }

What it does

runSequential in pkg/agent/adk/run_orchestration.go is a short loop:

currentMessage := userMessage
for i, sa := range a.config.SubAgents {
    emitDebug({type: "delegate", tool: sa.ID(), iteration: i})
    resp, err := sa.Run(ctx, currentMessage)
    if err != nil { return fmt.Errorf("sequential agent X failed at Y: %w", err) }
    lastResponse = resp
    currentMessage = resp.Content
}
return lastResponse

Key properties:

  • Pure pipeline of Content. Each sub-agent is invoked with the PREVIOUS sub-agent's Content field as its user message — no headers, no metadata, no shared exchange. If a stage needs to forward structured data, encode it in the response text (e.g. JSON the next stage parses).
  • Fail fast. First sub-agent error aborts the whole pipeline with sequential agent <parent>: <child>: <err> wrapped.
  • Each sub-agent is a full agent. It can be any type (ReAct, plan-execute, even another sequential). It carries its own model / memory / tools / guardrails / budget. The parent's config is NOT inherited.
  • The parent has no own loop. A tools: block on the parent is ignored — only sub_agents: drives execution. (Use a supervisor when you want the parent itself to call tools.)
  • Delegate event per stage. The parent emits a delegate debug event with each sub-agent's ID and iteration index, so a tracer can render the pipeline as labelled segments.

Configuration

Field Type Default Description
id string — Parent ID, used in error messages and the delegate trace.
type string — Must be sequential.
sub_agents list required Ordered list of nested AgentDefinitions. Empty list runs nothing and returns nil.
model block — NOT used by the parent. Sub-agents bring their own.
tools, memory, guardrails, budget, etc. — ignored Sequential delegates entirely — these settings only have effect if you place them on the sub-agents.

Behavior notes

  • Errors are NOT recoverable — the first failing sub-agent aborts the pipeline. To make a stage optional or retry-friendly, wrap it inside the sub-agent itself (e.g. give it a try/catch tool or a retry policy).
  • Memory is per-sub-agent. If a downstream stage needs prior context beyond the previous stage's content, give it shared memory (type: redis with a common namespace) and let it fetch what it needs.
  • Sequential is the LLM-driven counterpart to flow.SequentialFlow in pkg/agent/flow/ — SequentialFlow composes engine.Processors on an Exchange; this composes agents on messages. See flows for the processor-side variant.
  • Streaming is not supported — RunStream falls back to non-streaming and chunks the final text for display.

Example

A three-stage doc-processing pipeline:

agents:
  - id: doc-pipeline
    type: sequential
    sub_agents:
      - id: extractor
        type: react
        model: { provider: openai, model: gpt-4o-mini }
        system_prompt: |
          Extract the bullet-point facts from the user's message.
          Reply with JSON: {"facts": ["...", ...]}
        tools: []
      - id: enricher
        type: react
        model: { provider: anthropic, model: claude-sonnet-4-7 }
        system_prompt: |
          You receive a JSON object {"facts": [...]}. For each fact,
          add a one-line citation source (you may use web tools).
          Reply with JSON: {"enriched": [{"fact": "...", "source": "..."}]}
        tools:
          - { name: web-fetch, type: function, function: web.fetch }
      - id: writer
        type: react
        model: { provider: anthropic, model: claude-sonnet-4-7 }
        system_prompt: |
          You receive a JSON object {"enriched": [...]}. Produce a
          400-word brief in Markdown citing each source.
        tools: []

Invoke with raw user text — the extractor turns it into structured facts, the enricher adds citations, the writer drafts the final brief.

Source

  • pkg/agent/adk/run_orchestration.go — runSequential.
  • pkg/agent/adk/agent.go — Run dispatch on TypeSequential.
  • pkg/workflow/definition.go — AgentDefinition.SubAgents.

See also

  • parallel — fan-out instead of pipeline.
  • supervisor — dynamic LLM-chosen delegation.
  • flows — flow.SequentialFlow for processor-side composition.
  • plan-execute — when you want the LLM to PLAN the steps instead of fixing them in YAML.