toolwire

package
v0.15.3 Latest Latest
Warning

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

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

Documentation

Overview

Package toolwire states the invariant every provider adapter is held to: each tool a model is offered arrives on the wire with every argument it declares, with the required ones still required, and with each argument's own schema intact.

mast #154 shipped a release in which every tool reached Claude as a name with an empty schema; it passed two judged nightlies because nothing compared what the model was handed against what was declared. The comparison lives here, shared, so no adapter is held to a weaker check than its siblings. An adapter supplies one thing: a reader that pulls its own wire spelling out of a captured request body into a Wire.

Products keep the other half — the catalog captured from their own agent rigs, which cannot move here — and run it through the library's adapters with this Verify.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Summary

func Summary(catalog []Entry) string

Summary renders a catalog as one line per tool, so a failure says what was actually checked.

func Verify

func Verify(catalog []Entry, wire Wire) []string

Verify compares what each declaration promised against what the adapter emitted, and returns one line per violation — empty when the conversion was faithful. Each check is a real outage, not a cosmetic mismatch:

  • Every tool is on the wire. A tool never shown cannot be called.
  • A tool with arguments arrives with a non-empty properties map (mast #154 exactly).
  • Every argument name survives, and none is invented.
  • Every required argument is still required; demoted, the model may omit it and the tool fails at dispatch.
  • Each argument's own schema survives as a non-empty object.

Types

type Entry

type Entry struct {
	// Name is the function name the model calls.
	Name string
	// Spelling records which declaration field carried the schema —
	// "Parameters" (typed *genai.Schema), "ParametersJsonSchema", or
	// "none". It names the converter branch in a failure.
	Spelling string
	// Rig names where the tool came from, so a failure says where to
	// look.
	Rig string
	// Declaration is the genai declaration, verbatim.
	Declaration *genai.FunctionDeclaration
	// Props are the argument names the declaration advertises, sorted.
	// Empty means the tool takes no arguments.
	Props []string
	// Required are the argument names marked required, sorted.
	Required []string
}

Entry is one declared tool and the facts derived from its declaration.

func EntryFor

func EntryFor(rig string, d *genai.FunctionDeclaration) (Entry, error)

EntryFor derives an Entry from a declaration, so expectations come from the declaration itself and cannot go stale beside it.

func (Entry) HasParams

func (e Entry) HasParams() bool

HasParams reports whether the tool advertises any arguments.

type Wire

type Wire map[string]map[string]any

Wire is what an adapter actually sent, read back out of the captured request body: tool name -> the JSON schema object its arguments were described by.

Jump to

Keyboard shortcuts

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