agent

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildInstructions

func BuildInstructions(modelID string, data prompt.SectionData) string

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func New

func New(ws *code.Workspace, cfg *harness.Config, ui code.UI, options ...Options) *Agent

New constructs a built-in code agent. Options are optional so existing callers keep the default tool set; multiple values are combined.

func (*Agent) Cancel

func (a *Agent) Cancel(id string)

func (*Agent) Close

func (a *Agent) Close() error

func (*Agent) ContextStats added in v0.11.2

func (a *Agent) ContextStats(id string) (harness.ContextStats, bool)

func (*Agent) DeleteSession

func (a *Agent) DeleteSession(_ context.Context, id string) error

func (*Agent) Effort

func (a *Agent) Effort(sessionID string) (string, []string)

func (*Agent) ExecSession added in v0.16.4

func (a *Agent) ExecSession(id string, execID int) (shell.ExecSessionInfo, bool)

func (*Agent) ExecSessions added in v0.16.4

func (a *Agent) ExecSessions(id string) []shell.ExecSessionInfo

ExecSessions exposes commands that exec_command left running so web clients can present them with the session's other background work.

func (*Agent) FetchModels added in v0.8.2

func (a *Agent) FetchModels(ctx context.Context)

func (*Agent) HasSession

func (a *Agent) HasSession(id string) bool

func (*Agent) HistorySnapshot added in v0.12.9

func (a *Agent) HistorySnapshot(id string) code.HistorySnapshot

func (*Agent) HistoryVersion added in v0.12.9

func (a *Agent) HistoryVersion(id string) code.HistoryVersion

func (*Agent) ListSessions

func (a *Agent) ListSessions(_ context.Context) ([]code.SessionInfo, error)

func (*Agent) LoadSession

func (a *Agent) LoadSession(_ context.Context, id string) error

func (*Agent) LoadTurnQueue added in v0.15.8

func (a *Agent) LoadTurnQueue(sessionID string) (code.TurnQueueState, error)

func (*Agent) Messages

func (a *Agent) Messages(id string) []harness.Message

func (*Agent) Models

func (a *Agent) Models(sessionID string) ([]model.Model, string)

func (*Agent) Modes added in v0.8.0

func (a *Agent) Modes(sessionID string) ([]code.Mode, string)

func (*Agent) Name

func (a *Agent) Name() string

func (*Agent) NewSession

func (a *Agent) NewSession(_ context.Context) (string, error)

func (*Agent) Recap added in v0.11.2

func (a *Agent) Recap(ctx context.Context, id string) (string, error)

func (*Agent) RoleModel added in v0.14.10

func (a *Agent) RoleModel(role string) (harness.ModelOption, bool)

RoleModel resolves "main", "plan", or "utility" without a session. An empty role selects main; session-derived configs replace this with a resolver whose empty role follows the session's active mode.

func (*Agent) RunningTaskCount added in v0.11.2

func (a *Agent) RunningTaskCount() int

RunningTaskCount sums running background agents across every live session, so quitting warns about agents outside the currently viewed session too.

func (*Agent) Save

func (a *Agent) Save(id string) error

func (*Agent) SaveTurnQueue added in v0.15.8

func (a *Agent) SaveTurnQueue(sessionID string, state code.TurnQueueState) error

func (*Agent) Schedules added in v0.12.19

func (a *Agent) Schedules(id string) schedule.Store

Schedules exposes the session's scheduled tasks so UI surfaces can list them alongside its background agents.

func (*Agent) Send

func (a *Agent) Send(ctx context.Context, id string, input []harness.Content) (iter.Seq2[harness.Message, error], error)

func (*Agent) SessionsDir

func (a *Agent) SessionsDir() string

func (*Agent) SetEffort

func (a *Agent) SetEffort(_ context.Context, sessionID, value string) error

func (*Agent) SetMode added in v0.8.0

func (a *Agent) SetMode(_ context.Context, sessionID, modeID string) error

func (*Agent) SetModel

func (a *Agent) SetModel(_ context.Context, sessionID, id string) error

SetModel applies to the session's current role: picking a model while in plan mode configures planning, otherwise coding.

func (*Agent) SetUI

func (a *Agent) SetUI(ui code.UI)

func (*Agent) Steer added in v0.10.9

func (a *Agent) Steer(_ context.Context, id string, input code.TurnInput) error

func (*Agent) StopExecSession added in v0.16.4

func (a *Agent) StopExecSession(id string, execID int) error

func (*Agent) Tasks added in v0.11.2

func (a *Agent) Tasks(id string) *task.Registry

Tasks exposes the session's background-agent registry so UI surfaces can list running agents and deliver completion notifications.

func (*Agent) Tools

func (a *Agent) Tools(id string) []tool.Tool

func (*Agent) TurnFeatures added in v0.10.9

func (a *Agent) TurnFeatures(string) code.TurnFeatures

func (*Agent) Usage

func (a *Agent) Usage(id string) harness.Usage

func (*Agent) Workspace

func (a *Agent) Workspace() *code.Workspace

type Options added in v0.15.9

type Options struct {
	// RequireSessionContext disables single-client prompt routing fallbacks.
	RequireSessionContext  bool
	IsolateSessionSettings bool
	DisableShell           bool
	DisableWebSearch       bool
	DisableWebFetch        bool

	// Telemetry overrides the pipeline on the underlying agent.Config. A nil
	// value inherits that config, including automatic standard OTEL environment
	// configuration from agent.DefaultConfig.
	Telemetry *telemetry.Telemetry

	// ShutdownTelemetryOnClose transfers ownership of the selected telemetry
	// pipeline to this Agent. The Agent closes associated workspace MCP sessions
	// before shutting the pipeline down so their final metrics can be exported.
	// Most embedders should leave ownership with the component that created the
	// pipeline.
	ShutdownTelemetryOnClose bool
}

Options controls the built-in tools exposed by an Agent. Environment variables are resolved once when the agent starts and are combined with the explicitly supplied options.

Jump to

Keyboard shortcuts

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