Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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:
- 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).
- 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.