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 (*Agent) ClearMessages ¶
func (a *Agent) ClearMessages()
ClearMessages wipes the conversation history.
func (*Agent) Messages ¶
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 ¶
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 ¶
SetMessages replaces the conversation slice. Used by /compact to write back the result of an ad-hoc strategy.