orchestrator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxInterpolateLen = 4000

DefaultMaxInterpolateLen is the maximum number of characters substituted into a {{task-id.output}} placeholder (DEC-003).

Variables

This section is empty.

Functions

func Interpolate

func Interpolate(msg string, results map[string]string, maxLen int) string

Interpolate replaces {{task-id.output}} placeholders in msg with the corresponding task output from results. Unknown references are left as-is. Output values are truncated to maxLen characters (0 = DefaultMaxInterpolateLen).

func NoOpProgress

func NoOpProgress(string, string, TaskStatus)

NoOpProgress is a ProgressFunc that does nothing. Used when orchestrator.progressUpdates is false (the default).

Types

type ChatResponse

type ChatResponse = agentapi.Response

ChatResponse is an alias for agentapi.Response (kept for backward compatibility).

type Chatter

type Chatter = agentapi.Chatter

Chatter is an alias for agentapi.Chatter.

type Dispatcher

type Dispatcher struct {
	// Agents maps agent ID → Chatter.
	Agents map[string]Chatter
	// MaxConcurrent limits simultaneous subtasks (default 5).
	MaxConcurrent int
	// Limiter replaces the internal semaphore when set (for global concurrency control).
	Limiter Limiter
}

Dispatcher executes a validated TaskGraph by running subtasks in goroutines, respecting dependencies, enforcing max concurrency, and handling partial failures.

func (*Dispatcher) Execute

func (d *Dispatcher) Execute(ctx context.Context, graph TaskGraph, progress ProgressFunc) (ResultSet, error)

Execute validates the graph, topologically sorts it, then runs all tasks using goroutines with dependency tracking and a semaphore for max concurrency. progress is called after each task completes; pass NoOpProgress to disable.

type Limiter

type Limiter interface {
	Acquire(ctx context.Context) error
	Release()
}

Limiter provides a concurrency-limiting semaphore. When set on Dispatcher, it replaces the internal channel-based semaphore for global concurrency control.

type ProgressFunc

type ProgressFunc func(taskID string, agentID string, status TaskStatus)

ProgressFunc is called after each task completes (or fails) during dispatch. It must be safe to call from multiple goroutines concurrently.

type ResultSet

type ResultSet struct {
	Tasks []TaskResult `json:"tasks"`
}

ResultSet is the complete set of results returned by the dispatcher.

func (*ResultSet) ByID

func (rs *ResultSet) ByID(id string) *TaskResult

ByID returns the result for a given task ID, or nil if not found.

func (*ResultSet) FormatAppendix

func (rs *ResultSet) FormatAppendix() string

FormatAppendix renders the result set in the <task-appendix> format expected by the orchestrator response.

type Task

type Task struct {
	ID             string   `json:"id"`
	AgentID        string   `json:"agent_id"`
	Message        string   `json:"message"`
	DependsOn      []string `json:"depends_on"`
	Blocking       bool     `json:"blocking"`
	TimeoutSeconds int      `json:"timeout_seconds,omitempty"`
}

Task is a single unit of work in a task graph.

type TaskGraph

type TaskGraph struct {
	Tasks []Task `json:"tasks"`
}

TaskGraph is the structured plan produced by the orchestrator LLM.

func ParseTaskGraph

func ParseTaskGraph(data []byte) (TaskGraph, error)

ParseTaskGraph unmarshals a JSON task graph, returning a validation error if the JSON is malformed.

type TaskResult

type TaskResult struct {
	ID         string        `json:"id"`
	AgentID    string        `json:"agent_id"`
	Status     TaskStatus    `json:"status"`
	Output     string        `json:"output"`
	Error      string        `json:"error,omitempty"`
	DurationMs int64         `json:"duration_ms"`
	Duration   time.Duration `json:"-"`
}

TaskResult holds the outcome of a single dispatched task.

type TaskStatus

type TaskStatus string

TaskStatus represents the execution status of a task.

const (
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusRunning   TaskStatus = "running"
	TaskStatusSuccess   TaskStatus = "success"
	TaskStatusFailed    TaskStatus = "failed"
	TaskStatusCancelled TaskStatus = "cancelled"
	TaskStatusTimeout   TaskStatus = "timeout"
)

Jump to

Keyboard shortcuts

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