agent.go

Overview

This file implements the SequentialAgent, a specialized workflow agent designed to execute multiple sub-agents strictly in a fixed, sequential order exactly once. It belongs to the sequentialagent package and provides a mechanism to compose AI workflows where steps must run one after another in a deterministic pipeline fashion.

The SequentialAgent is constructed as a thin wrapper around the more generic LoopAgent configured to run a single iteration (MaxIterations: 1). This design enables reuse of the LoopAgent’s orchestration and sub-agent management logic while enforcing a single-pass execution.

The primary use case for this agent is when the execution order matters and you want each sub-agent to run once in strict sequence, ensuring that the output or side effects of earlier sub-agents can influence subsequent ones.

Package and Imports

Classes and Types

Config

type Config struct {
	AgentConfig agent.Config
}

Functions and Methods

New(cfg Config) (agent.Agent, error)

func New(cfg Config) (agent.Agent, error)

Implementation Details

Interaction with Other System Components

Visual Diagram

flowchart TD
Start[Start Sequential Agent]
SubAgent1[Run Sub-Agent 1]
SubAgent2[Run Sub-Agent 2]
SubAgentN[Run Sub-Agent N]
End[End Sequential Agent]
Start --> SubAgent1 --> SubAgent2 --> SubAgentN --> End

This flowchart illustrates the core workflow of the SequentialAgent: it runs each sub-agent one after another in a strict order and only once, forming a linear pipeline.


References to Related Topics