agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package agent provides the agent system for Sol, enabling multiple specialized agents with different capabilities and system prompts.

Index

Constants

View Source
const (
	AgentBuild      = "build"
	AgentPlan       = "plan"
	AgentExplore    = "explore"
	AgentGeneral    = "general"
	AgentCompaction = "compaction"
)

Built-in agent names.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the global agent registry.

Functions

func List

func List() []string

List returns all agent names from the default registry.

func MustRegister

func MustRegister(name string, factory Factory)

MustRegister adds a factory to the default registry, panicking on error.

func Register

func Register(name string, factory Factory) error

Register adds a factory to the default registry.

Types

type Agent

type Agent struct {
	// Name is the unique identifier for this agent (e.g., "build", "explore").
	Name string

	// Model is the full provider/model string (e.g., "anthropic/claude-sonnet-4-20250514").
	// Parsed internally via provider.ParseModel().
	Model string

	// SystemPrompt is the base system prompt for this agent.
	// Empty means use the model-specific default prompt.
	SystemPrompt string

	// EnvironmentPrompt is appended to the system prompt with environment context.
	// If empty, Sol appends default environment info (workDir, platform, date).
	// Set this to override with custom context (e.g. conversation ID, platform type).
	EnvironmentPrompt string

	// Tools is the exact set of tools this agent can use. No filtering.
	Tools tool.Set

	// MaxSteps limits how many steps this agent can take (0 = default 50).
	MaxSteps int

	// Temperature sets the model temperature for this agent (nil = provider default).
	Temperature *float64

	// HistoryPolicy controls which message parts from conversation history are
	// included when building the LLM context. Zero value includes everything
	// (matching opencode behavior).
	HistoryPolicy HistoryPolicy
}

Agent defines an agent configuration — what model, tools, and prompt to use.

func Get

func Get(name, modelID string) (*Agent, bool)

Get retrieves an agent from the default registry.

func MustGet

func MustGet(name, modelID string) *Agent

MustGet retrieves an agent from the default registry, panicking if not found.

func NewBuildAgent

func NewBuildAgent(modelID string) *Agent

NewBuildAgent creates the default full-access agent for software engineering tasks. Uses the model-specific default prompt (SystemPrompt is empty).

func NewCompactionAgent

func NewCompactionAgent(_ string) *Agent

NewCompactionAgent creates a hidden agent for context compaction.

func NewExploreAgent

func NewExploreAgent(modelID string) *Agent

NewExploreAgent creates a specialized subagent for codebase exploration.

func NewGeneralAgent

func NewGeneralAgent(modelID string) *Agent

NewGeneralAgent creates a general-purpose subagent for delegated tasks.

func NewPlanAgent

func NewPlanAgent(modelID string) *Agent

NewPlanAgent creates a read-only agent for planning and design.

type Factory

type Factory func(modelID string) *Agent

Factory creates an Agent with tools appropriate for the given model ID.

func GetFactory

func GetFactory(name string) (Factory, bool)

GetFactory retrieves a factory from the default registry.

type HistoryPolicy

type HistoryPolicy struct {
	ExcludeReasoning bool // Strip ReasoningParts from assistant messages
	ExcludeToolCalls bool // Strip ToolCallParts + skip tool-role messages
	ExcludeFiles     bool // Strip ImageParts/FileParts from all messages — stripped at PERSIST time, never reach history

	// FilesRetainTurns keeps image/file parts in the N most recent user turns
	// of history, then strips them when loading older messages. 0 disables
	// (nothing stripped at load time). Only meaningful when ExcludeFiles=false
	// — with ExcludeFiles=true files are already gone before they reach history.
	FilesRetainTurns int
}

HistoryPolicy controls which message parts from conversation history are included when building the LLM context. Zero value includes everything.

type Registry

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

Registry manages available agent factories.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new agent registry.

func (*Registry) Get

func (r *Registry) Get(name, modelID string) (*Agent, bool)

Get retrieves an agent by name, building it with the given model ID.

func (*Registry) GetFactory

func (r *Registry) GetFactory(name string) (Factory, bool)

GetFactory retrieves the factory function for an agent by name.

func (*Registry) List

func (r *Registry) List() []string

List returns all registered agent names.

func (*Registry) MustGet

func (r *Registry) MustGet(name, modelID string) *Agent

MustGet retrieves an agent by name, panicking if not found.

func (*Registry) MustRegister

func (r *Registry) MustRegister(name string, factory Factory)

MustRegister adds a factory to the registry, panicking on error.

func (*Registry) Register

func (r *Registry) Register(name string, factory Factory) error

Register adds a factory to the registry.

Jump to

Keyboard shortcuts

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