agent

package
v0.0.0-...-77aa4db Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package agent encapsulates the agent loop. The root REPL holds one Agent; subagents (spawned by the delegate tool) are additional Agents with their own state, system prompt, and tool subset.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Name      string                           // shown in the spinner label; "" for root
	Provider  provider.Provider                //
	Tools     *tool.Registry                   // curated registry for this agent
	Compactor compact.CompactionStrategy       //
	System    string                           // system prompt
	MaxTurns  int                              // hard cap on tool-use iterations
	Verbose   bool                             // print compaction before/after
	LogPrefix string                           // prefix for tool-call log lines
	Quiet     bool                             // suppress assistant-text printing (set for subagents)
	Confirm   func(prompt, detail string) bool // nil = auto-approve every tool call. detail is optional long-form (e.g. a diff)
	// contains filtered or unexported fields
}

Agent owns one conversation: a provider, a tool registry, a compaction strategy, and a slice of messages. The same struct serves the root REPL and any subagents.

func New

func New(p provider.Provider, system string, tools *tool.Registry) *Agent

func (*Agent) ClearMessages

func (a *Agent) ClearMessages()

ClearMessages wipes the conversation history.

func (*Agent) Messages

func (a *Agent) Messages() []api.Message

Messages returns the agent's conversation slice. Callers (e.g. /compact) may read it, but should not mutate it directly — use SetMessages instead.

func (*Agent) Send

func (a *Agent) Send(ctx context.Context, prompt string) (string, error)

Send appends a user message and runs the tool-use loop until the model stops requesting tools (or MaxTurns is reached). Returns the final assistant text concatenation, which is printed live as it arrives for the root agent and silently accumulated for subagents.

func (*Agent) SetMessages

func (a *Agent) SetMessages(m []api.Message)

SetMessages replaces the conversation slice. Used by /compact to write back the result of an ad-hoc strategy.

Jump to

Keyboard shortcuts

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