Help us shape the future of Go! Take the 2026 Go Developer Survey

tools

command
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

Tools Example

This example shows the smallest useful tool contract for host applications.

Tools are host-owned typed actions. The Agent may request them, policy may approve them, and the executor runs them with schema validation and timeouts.

The example includes:

  • Spec.Permission: declares whether a tool is read, write, or exec so policy can approve it.
  • Spec.Schema: validates model-supplied JSON before the tool body runs.
  • Spec.Timeout: bounds tool and middleware execution.
  • Result.ForLLM: model-visible observation for the next LLM turn.
  • Result.ForUser: host-visible output for UI or caller surfaces.
  • Result.Silent: replaces a successful result's content in model context with a short acknowledgement.
  • Result.IsError: marks a recoverable domain error that the model can correct on a later turn.

Return a Go error for executor failures that should abort the current run path. Return Result{IsError: true, ForLLM: "..."} for recoverable domain errors such as invalid business state or correctable arguments.

Run it with:

go run ./examples/tools

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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