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

agentmode

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package agentmode provides a context provider that tracks the agent's operating mode (e.g. "plan" or "execute") in the session state and provides tools for querying and switching modes.

It enables agents to operate in distinct modes during long-running HITL tasks — for example, an interactive planning mode vs an autonomous execution mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Modes is the set of available modes. If nil, defaults to "plan" and "execute".
	// An empty, non-nil slice is invalid.
	Modes []Mode

	// DefaultMode is the initial mode. Must be one of the configured Modes.
	// If nil, the first mode is used.
	DefaultMode *string

	// Instructions overrides the default instruction template.
	// Use {available_modes} and {current_mode} as placeholders.
	Instructions *string

	// DisableModeSetTool omits the built-in mode_set tool while retaining mode
	// state and instructions.
	DisableModeSetTool bool

	// DisableModeGetTool omits the built-in mode_get tool while retaining mode
	// state and instructions.
	DisableModeGetTool bool
}

Config configures the agent mode provider.

type Mode

type Mode struct {
	Name         string
	Instructions string
}

Mode describes a named operating mode and its behavioral instructions.

type Provider

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

Provider is an agent mode context provider. Use New to create. Provider can be used directly in agent configuration.

func New

func New(cfg Config) *Provider

New creates a new agent mode context provider. A zero-value Config uses defaults (plan/execute modes).

Panics if the configuration contains duplicate names, an empty mode name or instructions, or a default mode that is not in the configured set.

func (*Provider) Invoked

func (p *Provider) Invoked(ctx context.Context, invoked agent.InvokedContext) error

func (*Provider) Invoking

func (p *Provider) Invoking(ctx context.Context, invoking agent.InvokingContext) ([]*message.Message, []agent.Option, error)

func (*Provider) Mode added in v0.1.1

func (p *Provider) Mode(session *agent.Session) string

Mode returns the current operating mode from session state. If no state has been persisted yet, it returns the configured default mode.

func (*Provider) SetMode

func (p *Provider) SetMode(session *agent.Session, mode string, disableNotification bool) error

SetMode sets the operating mode in session state. It returns an error if the mode is invalid or no session is available. Set disableNotification to true to suppress the next mode-change notification and clear any pending one.

Jump to

Keyboard shortcuts

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