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

agent

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package agent runs the step loop: query the model, execute tool calls, repeat.

Index

Constants

View Source
const (
	StatusSubmitted   = "Submitted"
	StatusCompleted   = "Completed" // model stopped calling tools without the submit marker
	StatusStepLimit   = "StepLimitExceeded"
	StatusCostLimit   = "CostLimitExceeded"
	StatusTimeLimit   = "TimeLimitExceeded"
	StatusInterrupted = "Interrupted"
	StatusError       = "Error"
)
View Source
const SubmitMarker = "COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT"

Variables

This section is empty.

Functions

func SystemPrompt added in v0.4.0

func SystemPrompt(cfg config.AgentConfig, root string, skipAgentsMD bool, readOnly ...bool) string

SystemPrompt returns the effective system prompt a run rooted at root would use, given cfg and whether AGENTS.md is skipped. It is exported so callers can validate a checkpoint against the current configuration.

func ToolSignature added in v0.4.0

func ToolSignature(readOnly ...bool) string

ToolSignature fingerprints the definitions plus an execution contract version. Bump the prefix when tool semantics change without a spec change.

func ValidateResume added in v0.4.0

func ValidateResume(t *trajectory.Trajectory, cfg config.AgentConfig, root string) error

ValidateResume runs before provider setup, using only the explicit execution root and current config. Checkpoint paths and credentials are never executed or loaded from metadata.

Types

type Agent

type Agent struct {
	Model     model.Model
	ModelName string
	Tools     *tools.Executor
	Config    config.AgentConfig
	Out       io.Writer // progress log; nil discards
	Err       io.Writer // warnings; nil discards
	Verbose   bool
	// Streamed means the model already wrote its text to Out as it arrived.
	Streamed bool
	// SkipAgentsMD stops Run from appending the nearest AGENTS.md at or above
	// <root> to the system prompt.
	SkipAgentsMD bool
	// NoCompact turns off context compaction: the full history is always
	// sent, and a context-overflow error ends the run.
	NoCompact bool
	// OnStep is called after every step, e.g. to save the trajectory. A
	// non-nil error stops the run.
	OnStep func(*trajectory.Trajectory) error
	// OnEvent receives machine-readable progress events when configured.
	OnEvent func(string, map[string]any)
	// Resume, when non-nil, continues that trajectory instead of starting a
	// fresh run: its messages, accounting totals, and steps are the starting
	// state, and a continuation notice is appended before the first request.
	Resume       *trajectory.Trajectory
	ResumeSource string // audit-only input path for resume provenance
}

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, task string) *trajectory.Trajectory

Run executes task until submission, a limit, or an error. It always returns a trajectory describing how the run ended.

Jump to

Keyboard shortcuts

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