agentmode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 10 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 empty, defaults to "plan" and "execute".
	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
}

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) GetMode

func (p *Provider) GetMode(opts ...agent.Option) string

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

func (*Provider) Invoked

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

Invoked implements agent.ContextProvider by delegating to the wrapped provider. The wrapped provider is configured without a Store, so this is a no-op on success.

func (*Provider) Invoking

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

Invoking implements agent.ContextProvider by delegating to the wrapped provider, applying this provider's context/instructions to the invocation.

func (*Provider) SetMode

func (p *Provider) SetMode(mode string, opts ...agent.Option) error

SetMode sets the operating mode in the session, validating it against the provider's configured modes. Returns an error if the mode is invalid or no session is available.

Jump to

Keyboard shortcuts

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