task

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Description    string
	ExpectedOutput string
	Agent          *agent.Agent
	Context        []*Task
	Tools          []tools.Tool
	AsyncExecution bool
	HumanInput     bool
	Callback       callback.Callback
	OutputFile     string
	FlowNodeID     string
	// @sk-task guardrails#T1.2: guardrails validated after agent returns (AC-007)
	Guardrails          []guardrail.Guardrail
	GuardrailMaxRetries int
	// @sk-task conditional-tasks#T2.1: condition evaluated before agent call (AC-001–AC-005)
	Condition func(ctx context.Context, previousOutput string) (bool, error)
}

Config defines the configuration for a Task.

type Task

type Task struct {
	Config
	ID              string
	Processed       bool
	Failed          bool
	Error           error
	Output          string
	OutputCondition string
	NextPaths       map[string]string
	// @sk-task replay-system#T1.1: per-task usage and input context for checkpoint capture (AC-006)
	Usage        map[string]int    // token usage for this task execution; set before saveCheckpoint
	InputContext map[string]string // context results passed to this task; set before saveCheckpoint
	// @sk-task conditional-tasks#T2.1: skip state set when condition returns false (AC-002)
	Skipped bool
}

Task represents a unit of work to be executed by an agent.

func New

func New(cfg Config) *Task

New creates a new Task with the given configuration and a unique ID.

func (*Task) Execute

func (t *Task) Execute(ctx context.Context, contextResults map[string]string, previousOutput ...string) (string, error)

Execute runs the task and returns its output, handling condition evaluation, human input, context dependencies and guardrails. previousOutput is the output of the immediately preceding task (empty string for first task).

func (*Task) SetNextPath

func (t *Task) SetNextPath(condition, taskID string)

SetNextPath defines a conditional transition from this task to another task by ID.

Jump to

Keyboard shortcuts

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