Help us shape the future of Go! Take the 2026 Go Developer Survey

flow

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	FromID    string
	ToID      string
	Condition *OutputCondition
}

Edge represents a directed connection between two flow nodes, optionally conditional.

type Flow

type Flow struct {
	AfterNode   func(nodeID string, node *Node) // optional callback after each node execution, used for checkpointing
	BeforeLevel func() bool                     // optional hook called before each level; return false to stop
	// contains filtered or unexported fields
}

Flow manages a DAG of nodes and edges for agent-based workflow execution.

func New

func New() *Flow

New creates an empty Flow ready for nodes and edges to be added.

func (*Flow) AddConditionalEdge

func (f *Flow) AddConditionalEdge(fromID, toID string, cond OutputCondition) error

AddConditionalEdge creates a directed edge with an output condition for routing.

func (*Flow) AddEdge

func (f *Flow) AddEdge(fromID, toID string) error

AddEdge creates a directed edge between two existing flow nodes.

func (*Flow) AddNode

func (f *Flow) AddNode(id string, agent *agent.Agent, task string) error

AddNode adds a new node to the flow with the given ID, agent, and task description.

func (*Flow) OnCallback

func (f *Flow) OnCallback(cb callback.Callback)

OnCallback sets the callback function for flow lifecycle events.

func (*Flow) Run

func (f *Flow) Run(ctx context.Context) (*Result, error)

Run executes all nodes in the flow using topological ordering and parallel level execution.

type Node

type Node struct {
	ID    string
	Agent *agent.Agent
	Task  string

	Result string
	Error  error
}

Node represents a single step in a flow DAG with an associated agent and task.

type OutputCondition

type OutputCondition struct {
	Field    string `json:"field"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

OutputCondition defines a condition for evaluating task output to determine flow routing.

type Result

type Result struct {
	NodeResults    map[string]*Node
	ExecutionOrder []string
}

Result contains the results and execution order from a flow run.

Jump to

Keyboard shortcuts

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