workflowagent

package
v1.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package workflowagent provides workflow agents for orchestrating multi-agent flows.

This package provides three types of workflow agents aligned with adk-go:

SequentialAgent

Runs sub-agents once, in the order they are listed:

agent, _ := workflowagent.NewSequential(workflowagent.SequentialConfig{
    Name:        "pipeline",
    Description: "Processes data through multiple stages",
    SubAgents:   []agent.Agent{stage1, stage2, stage3},
})

ParallelAgent

Runs sub-agents simultaneously in parallel:

agent, _ := workflowagent.NewParallel(workflowagent.ParallelConfig{
    Name:        "voters",
    Description: "Gets multiple perspectives simultaneously",
    SubAgents:   []agent.Agent{voter1, voter2, voter3},
})

LoopAgent

Runs sub-agents repeatedly for N iterations or until escalation:

agent, _ := workflowagent.NewLoop(workflowagent.LoopConfig{
    Name:          "refiner",
    Description:   "Iteratively refines output",
    SubAgents:     []agent.Agent{reviewer, improver},
    MaxIterations: 3,
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoop

func NewLoop(cfg LoopConfig) (agent.Agent, error)

NewLoop creates a LoopAgent.

LoopAgent repeatedly runs its sub-agents in sequence for a specified number of iterations or until a termination condition is met (escalate action).

Use LoopAgent when your workflow involves repetition or iterative refinement, such as revising code or refining outputs.

Example:

reviewer, _ := llmagent.New(llmagent.Config{...})
improver, _ := llmagent.New(llmagent.Config{...})

refiner, _ := workflowagent.NewLoop(workflowagent.LoopConfig{
    Name:          "refiner",
    Description:   "Iteratively refines output",
    SubAgents:     []agent.Agent{reviewer, improver},
    MaxIterations: 3,
})

func NewParallel

func NewParallel(cfg ParallelConfig) (agent.Agent, error)

NewParallel creates a ParallelAgent.

ParallelAgent runs its sub-agents in parallel in an isolated manner. All sub-agents receive the same input and run simultaneously.

This is beneficial for scenarios requiring multiple perspectives or attempts on a single task, such as:

  • Running different algorithms simultaneously
  • Generating multiple responses for review by an evaluation agent
  • Getting diverse perspectives on a problem

Example:

voter1, _ := llmagent.New(llmagent.Config{Name: "voter1", ...})
voter2, _ := llmagent.New(llmagent.Config{Name: "voter2", ...})
voter3, _ := llmagent.New(llmagent.Config{Name: "voter3", ...})

voters, _ := workflowagent.NewParallel(workflowagent.ParallelConfig{
    Name:        "voters",
    Description: "Gets multiple perspectives simultaneously",
    SubAgents:   []agent.Agent{voter1, voter2, voter3},
})

func NewSequential

func NewSequential(cfg SequentialConfig) (agent.Agent, error)

NewSequential creates a SequentialAgent.

SequentialAgent executes its sub-agents once, in the order they are listed. This is implemented as a LoopAgent with MaxIterations=1.

Use SequentialAgent when you want execution to occur in a fixed, strict order, such as a processing pipeline.

Example:

stage1, _ := llmagent.New(llmagent.Config{Name: "stage1", ...})
stage2, _ := llmagent.New(llmagent.Config{Name: "stage2", ...})
stage3, _ := llmagent.New(llmagent.Config{Name: "stage3", ...})

pipeline, _ := workflowagent.NewSequential(workflowagent.SequentialConfig{
    Name:        "pipeline",
    Description: "Processes data through multiple stages",
    SubAgents:   []agent.Agent{stage1, stage2, stage3},
})

Types

type LoopConfig

type LoopConfig struct {
	// Name is the agent name.
	Name string

	// DisplayName is the human-readable name (optional).
	DisplayName string

	// Description describes what the agent does.
	Description string

	// SubAgents are the agents to run in each iteration.
	SubAgents []agent.Agent

	// AgentType overrides the agent type. Defaults to TypeLoopAgent.
	AgentType agent.AgentType

	// MaxIterations is the maximum number of iterations.
	// If 0, runs indefinitely until any sub-agent escalates.
	MaxIterations uint
}

LoopConfig defines the configuration for a LoopAgent.

type ParallelConfig

type ParallelConfig struct {
	// Name is the agent name.
	Name string

	// DisplayName is the human-readable name (optional).
	DisplayName string

	// Description describes what the agent does.
	Description string

	// SubAgents are the agents to run in parallel.
	SubAgents []agent.Agent
}

ParallelConfig defines the configuration for a ParallelAgent.

type SequentialConfig

type SequentialConfig struct {
	// Name is the agent name.
	Name string

	// DisplayName is the human-readable name (optional).
	DisplayName string

	// Description describes what the agent does.
	Description string

	// SubAgents are the agents to run in sequence.
	SubAgents []agent.Agent
}

SequentialConfig defines the configuration for a SequentialAgent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL