Documentation
¶
Index ¶
- Constants
- Variables
- type Agent
- func (a *Agent) Backend() (string, string)
- func (a *Agent) Clear()
- func (a *Agent) Model() string
- func (a *Agent) RunTool(ctx context.Context, name string, input map[string]any) (string, bool)
- func (a *Agent) Send(ctx context.Context, userText string) (string, error)
- func (a *Agent) SendWith(ctx context.Context, userText string, imagePaths []string) (string, error)
- func (a *Agent) SendWithDisplay(ctx context.Context, promptText, displayText string, imagePaths []string) (string, error)
- func (a *Agent) SetApprover(fn func(context.Context, ApprovalRequest) (bool, error))
- func (a *Agent) SetBackend(provider llm.Provider, model string, compactor compact.Compactor) error
- func (a *Agent) SetEventHandler(fn func(Event))
- func (a *Agent) SetModel(model string)
- func (a *Agent) Steer(text string) bool
- func (a *Agent) Transcript() []llm.Message
- func (a *Agent) Usage() llm.Usage
- type ApprovalRequest
- type Config
- type Event
- type EventKind
- type ToolCallRef
Constants ¶
const DefaultMaxParallelTools = 8
const DefaultMaxTurns = 500
DefaultMaxTurns is a high safety fuse for runaway tool loops, not a normal work budget. Coding tasks can legitimately need many model/tool cycles; the model should usually stop because it is done, not because Neo reached this.
Variables ¶
var ErrMaxOutputTokens = errors.New("response truncated: model hit its max output tokens limit")
ErrMaxOutputTokens is returned when the model stops because it hit its output-token limit with no tool calls to continue on. Ending the turn (with the partial text) beats silently re-calling the provider until MaxTurns.
var ErrMaxTurns = errors.New("max turns reached")
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func (*Agent) Backend ¶ added in v0.3.0
Backend returns a consistent provider/model pair for display and session persistence.
func (*Agent) RunTool ¶ added in v0.2.0
RunTool runs a built-in tool directly through the same approval path used for model-requested tool calls. It emits the normal tool call/result events, but does not mutate the LLM transcript.
func (*Agent) SendWith ¶ added in v0.2.0
SendWith sends a user turn that may carry image attachments alongside the text. Images are placed before the text block, which is how vision models expect a "here's an image, now my question" message to be ordered. Paths that can't be read are skipped with an inline note rather than aborting the turn — attachments are best-effort.
func (*Agent) SendWithDisplay ¶ added in v0.6.0
func (a *Agent) SendWithDisplay(ctx context.Context, promptText, displayText string, imagePaths []string) (string, error)
SendWithDisplay sends promptText to the provider while preserving a shorter user-visible value for transcript replay, session titles, and local search. An empty displayText keeps the normal prompt text visible.
func (*Agent) SetApprover ¶ added in v0.2.0
func (*Agent) SetBackend ¶ added in v0.3.0
SetBackend changes the provider, model, and compactor as one unit. Callers switch only between turns, but the lock also keeps diagnostic readers and race-enabled tests from observing a half-switched backend.
func (*Agent) SetEventHandler ¶
SetEventHandler replaces the event callback. Useful when the consumer (e.g. a Bubble Tea program) isn't constructed until after the agent.
func (*Agent) Steer ¶ added in v0.3.0
Steer adds a user instruction to the active turn. The loop consumes it only after the current provider response and any requested tools have completed, preserving tool_use/tool_result pairing in the transcript.
func (*Agent) Transcript ¶
type ApprovalRequest ¶ added in v0.2.0
type Config ¶
type Config struct {
Model string
// System is the flattened system prompt. SystemBlocks, when set, carries the
// same prompt as ordered segments so the provider can place cache breakpoints;
// the loop passes both so providers can use whichever they support.
System string
SystemBlocks []llm.SystemBlock
Provider llm.Provider
Tools *tools.Registry
Compactor compact.Compactor
RequiresApproval func(string, map[string]any) bool
Approve func(context.Context, ApprovalRequest) (bool, error)
MaxTurns int
MaxParallelTools int
OnEvent func(Event)
Messages []llm.Message
Usage llm.Usage
}
type EventKind ¶
type EventKind string
const ( EventAssistantText EventKind = "assistant_text" EventAssistantCommentary EventKind = "assistant_commentary" EventParallelStart EventKind = "parallel_start" EventToolCall EventKind = "tool_call" EventToolResult EventKind = "tool_result" EventSteeringApplied EventKind = "steering_applied" EventDone EventKind = "done" EventError EventKind = "error" EventMaxTurnsReached EventKind = "max_turns_reached" )