workflow

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Ralph orchestration matches workflow/tool-ralph. Each round starts a fresh child agent for a fixed goal and receives a structured report. Continue carries a bounded handoff to the next round; complete succeeds, blocked needs human input, and exhausting maxRounds produces budget-limited.

Package workflow provides workflow orchestration and tool-workflow (S12), matching workflow/workflow upstream. Top-level Pipeline, Parallel, and Agent functions compose named executable Steps. Pipelines run serially, while parallel workflows run concurrent goroutines and aggregate ordered outputs. Context cancellation cascades to active steps; Result includes outputs and cancellation.

Index

Constants

View Source
const DefaultRalphMaxRounds = 256

DefaultRalphMaxRounds is the default round limit.

Variables

This section is empty.

Functions

func ValidateReport

func ValidateReport(r RoundReport) error

ValidateReport checks report consistency with its status.

Types

type Mode

type Mode string

Mode selects workflow execution mode.

const (
	ModePipeline Mode = "pipeline" // Sequential execution.
	ModeParallel Mode = "parallel" // Parallel execution.
)

type RalphResult

type RalphResult struct {
	Status RunStatus
	Rounds int
	Final  RoundReport
}

RalphResult contains the loop result.

func RunRalph

func RunRalph(ctx context.Context, objective string, runner RoundRunner, maxRounds, maxHandoffChars int) (*RalphResult, error)

RunRalph uses default rounds when maxRounds is nonpositive and enforces handoff length when maxHandoffChars is positive.

type Result

type Result struct {
	Name      string   `json:"name"`
	Outputs   []string `json:"outputs"`   // Step outputs in order.
	Cancelled bool     `json:"cancelled"` // Whether execution was canceled.
}

Result contains a workflow's output.

func (*Result) Errors

func (r *Result) Errors() error

Errors returns the first execution error, or nil.

type RoundReport

type RoundReport struct {
	Status    RoundStatus `json:"status"`
	Summary   string      `json:"summary"`
	Evidence  string      `json:"evidence"`
	NextSteps []string    `json:"nextSteps"`
	Blocker   string      `json:"blocker"`
}

RoundReport is a child agent's structured report.

type RoundRunner

type RoundRunner func(ctx context.Context, objective, priorHandoff string) (RoundReport, error)

RoundRunner receives the goal and previous handoff (empty initially) and returns a round report.

type RoundStatus

type RoundStatus string

RoundStatus identifies a round's outcome.

const (
	StatusContinue RoundStatus = "continue"
	StatusComplete RoundStatus = "complete"
	StatusBlocked  RoundStatus = "blocked"
)

type RunStatus

type RunStatus string

RunStatus identifies the final Ralph-loop outcome.

const (
	RunCompleted     RunStatus = "complete"
	RunBlocked       RunStatus = "blocked"
	RunBudgetLimited RunStatus = "budget-limited"
)

type SpawnAgentFunc

type SpawnAgentFunc func(ctx context.Context, backendName, input string) (string, error)

SpawnAgentFunc is injected to run a child on a named backend and return output.

type Step

type Step struct {
	Name string // Step name for diagnostics and summaries.
	Run  StepRunFunc
}

Step is the smallest executable workflow unit.

func Agent

func Agent(name, backendName, input string, spawn SpawnAgentFunc) *Step

Agent creates a child-agent step using the selected in-process, acp, or fork-copy backend.

func Seq

func Seq(w *Workflow) *Step

Seq wraps a nested workflow as one step for aggregation in a larger workflow.

type StepRunFunc

type StepRunFunc func(ctx context.Context) (string, error)

StepRunFunc executes a step and should return promptly when ctx is canceled.

type Workflow

type Workflow struct {
	Name  string
	Mode  Mode
	Steps []*Step
}

Workflow combines steps sequentially or in parallel.

func Parallel

func Parallel(name string, steps ...*Step) *Workflow

Parallel creates a workflow that executes steps concurrently.

func Pipeline

func Pipeline(name string, steps ...*Step) *Workflow

Pipeline creates a workflow that executes steps in order.

func (*Workflow) Run

func (w *Workflow) Run(ctx context.Context) (*Result, error)

Run executes the workflow and aggregates results, cascading ctx cancellation.

Jump to

Keyboard shortcuts

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