Documentation
¶
Overview ¶
Package loop implements the ReAct (Reasoning + Acting) agent loop.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine runs the agent loop: observe → think → act → repeat.
func New ¶
func New(client *llm.Client, registry *tool.Registry, maxIterations int, systemMessage string, renderer *render.Renderer, maxContext int) *Engine
New creates a new loop Engine. maxContext is the model's maximum context window in tokens. Pass 0 for no limit enforcement.
func (*Engine) RunWithMessages ¶
func (e *Engine) RunWithMessages(ctx context.Context, messages []llm.Message) (string, []llm.Message, error)
RunWithMessages executes the agent loop starting from a pre-built message history. The messages must include the system prompt (if any), all prior conversation turns, and the new user message as the last entry. Returns the final answer plus the full updated message history so callers can persist it (e.g. to a session file).
Use this for multi-turn conversations: load the session, append the new user message, call RunWithMessages, then save the returned messages.
func (*Engine) SetSkillLoader ¶
func (e *Engine) SetSkillLoader(sl SkillLoader)
SetSkillLoader sets the optional skill loader callback.
type SkillLoader ¶
SkillLoader is an optional callback that the loop engine calls before each LLM invocation to discover contextually relevant skills. The callback receives the latest user input and returns additional system context (formatted skill content) to inject, or empty string if no skills match.