toolagent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package toolagent provides a reference harness that lets the model call tools, each one gated on a human decision. Every call it makes is REQUIRES_APPROVAL: the host parks the turn, and only an approved call reaches the host's tool executor. The harness never runs a tool itself, holds no credentials, and keeps no state beyond the journal, so it is STATELESS_REPLAY.

Mediation is fixed by the harness, not by per-execution config: a caller that could choose it could also skip the approval.

Index

Constants

View Source
const MaxModelCalls = 8

MaxModelCalls bounds the model calls in one turn, so a model that keeps calling tools cannot loop forever. A turn that reaches it fails.

Variables

View Source
var ErrInvalidToolCall = errors.New("toolagent: model tool call needs a unique ID")

ErrInvalidToolCall is returned for a model tool call the harness cannot gate: no call ID, or an ID the turn already used. The host would refuse the call anyway; this names the cause.

View Source
var ErrTooManyModelCalls = errors.New("toolagent: too many model calls in one turn")

ErrTooManyModelCalls is returned when a turn reaches MaxModelCalls without a final answer.

Functions

func PublishTool

func PublishTool() api.ToolDefinition

PublishTool is the tool the documented executor example (docs/tool-executor-example.py) serves: publish one text. harnessnode offers it with HARNESS_KIND=tool. Each call returns a new value, so no caller can change another's schema.

Types

type Harness

type Harness struct {
	Model string
	// Tools are offered to the model in this order. Each name needs a host executor route for an
	// approved call to run.
	Tools []api.ToolDefinition
}

Harness offers Tools to the model on every call, turns each tool call in a completion into a REQUIRES_APPROVAL ToolCall, and feeds the result back until the model answers without one.

func (Harness) Describe

func (h Harness) Describe(context.Context) (api.Descriptor, error)

Describe declares the model, the gated tools and the stateless replay contract.

func (Harness) Run

func (h Harness) Run(ctx context.Context, start *api.Start, sink api.EventSink) error

Run builds the context from the journal, then alternates model calls and gated tool calls. On Resume the host serves recorded completions and receipts, so the same calls are re-emitted with the same IDs, keys and arguments; only an approved call that has no receipt runs.

Jump to

Keyboard shortcuts

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