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 ¶
- type Config
- type Mode
- type Provider
- func (p *Provider) GetMode(opts ...agent.Option) string
- func (p *Provider) Invoked(ctx context.Context, invoked agent.InvokedContext) error
- func (p *Provider) Invoking(ctx context.Context, invoking agent.InvokingContext) ([]*message.Message, []agent.Option, error)
- func (p *Provider) SetMode(mode string, opts ...agent.Option) error
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 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 ¶
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 ¶
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 ¶
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.