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

core

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultPrompt

func GetDefaultPrompt() string

GetDefaultPrompt loads the canonical agent_0 prompt from the role file

func GetPlatformContext

func GetPlatformContext(allowedCommands []string, allowedBuiltins []string) string

GetPlatformContext returns OS-specific guidance for agents with tiered tool hierarchy

func InjectAvailableRoles

func InjectAvailableRoles(prompt string, availableRoles []string) string

InjectAvailableRoles adds available agent role information to the prompt

func InjectPlatformContext

func InjectPlatformContext(prompt string, allowedCommands []string, allowedBuiltins []string) string

func InjectPlatformContextFromRegistry

func InjectPlatformContextFromRegistry(prompt string, reg tool.Registry) string

InjectPlatformContextFromRegistry adds OS + tool guidance using the live registry. It injects only once (recognized by PLATFORM_CONTEXT_START/END markers).

Types

type Agent

type Agent struct {
	ID        uuid.UUID
	Client    model.Client
	ModelName string
	Tools     tool.Registry
	Mem       memory.Store
	Vector    memory.VectorStore
	Vars      map[string]string // cloned on spawn to avoid shared mutation
	Tracer    trace.Writer
	Cost      *cost.Manager
	Prompt    string
	// Error handling configuration
	ErrorHandling ErrorHandlingConfig
	// contains filtered or unexported fields
}

Agent represents a conversational agent with LLM capabilities

func New

func New(client model.Client, modelName string, reg tool.Registry, mem memory.Store, vec memory.VectorStore, tr trace.Writer) *Agent

func (*Agent) Checkpoint

func (a *Agent) Checkpoint(ctx context.Context) error

Checkpoint persists the agent's current loop state under its ID.

func (*Agent) InvalidateToolCache

func (a *Agent) InvalidateToolCache()

InvalidateToolCache clears the cached tool name slice (call after mutating Tools)

func (*Agent) LoadState

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

LoadState restores memory from the store.

func (*Agent) Resume

func (a *Agent) Resume(ctx context.Context) error

Resume restores the agent's loop state from the store.

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, input string) (string, error)

func (*Agent) SaveState

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

func (*Agent) Trace

func (a *Agent) Trace(ctx context.Context, typ trace.EventType, data any)

type ErrorHandlingConfig

type ErrorHandlingConfig struct {
	// TreatErrorsAsResults makes tool errors visible to the agent instead of terminating
	TreatErrorsAsResults bool
	// MaxErrorRetries limits how many consecutive errors an agent can handle
	MaxErrorRetries int
	// IncludeErrorContext adds detailed error context to help with recovery
	IncludeErrorContext bool
}

ErrorHandlingConfig defines how the agent handles errors

func DefaultErrorHandling

func DefaultErrorHandling() ErrorHandlingConfig

DefaultErrorHandling returns sensible defaults for error handling

Jump to

Keyboard shortcuts

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