agent

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuiltinTools map[string]api.ToolSpec = map[string]api.ToolSpec{
	"Read":   toolbox.ReadFileTool,
	"Edit":   toolbox.ModifyFile,
	"Write":  toolbox.WriteFileTool,
	"Grep":   toolbox.GrepTool,
	"Glob":   toolbox.GlobTool,
	"Bash":   toolbox.BashTool,
	"Python": toolbox.PythonTool,
}

Functions

func ExecuteToolCalls

func ExecuteToolCalls(calls []api.ToolCall, available []api.ToolSpec, sandboxCfg *sandbox.ToolSandboxConfig) ([]api.ToolResult, error)

ExecuteToolCalls executes each of the provided api.ToolCalls by shelling out to `lmcli tool <name> <json>`, returning api.ToolResults. When sandboxCfg is non-nil and enabled, each invocation is wrapped in bwrap.

func RunLoop

func RunLoop(
	ctx context.Context,
	params api.RequestParameters,
	messages []api.Message,
	events chan<- api.Event,
	approval <-chan []api.ToolConfirmation,
	sandboxCfg *sandbox.ToolSandboxConfig,
)

RunLoop runs the completion and tool-call loop. All output — streaming chunks and control events — is delivered on the events channel, which is closed when the loop ends.

The loop uses the approval channel as a gate at two points:

  1. EventToolCallsRequested - the caller must send a []ToolConfirmation with one entry per tool call. Individual calls may be rejected (with an optional Reason that is sent back to the model).
  2. EventToolResults - the caller must send []ToolConfirmation{{Approved: true}} to continue or {{Approved: false}} to stop.

If the last message in messages is already a ToolCall, the loop skips the initial LLM call and goes straight to requesting confirmation for those tool calls. This is used for re-execution from the TUI.

Cancelling ctx stops the loop at the earliest opportunity.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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