toolcall

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toolcall is a small tool-correctness suite for voice agents.

Ten short spoken requests each need one tool call; two of them correct themselves mid-sentence. The client really executes every call it receives, computing the answer from that call's own arguments, and returns it after a delay while the agent may still be speaking. A task passes when exactly one call executed, its arguments are the ones asked for (after any correction), and the agent then speaks the result. Nothing here judges wording beyond "the result was said".

Index

Constants

This section is empty.

Variables

View Source
var Tools = []json.RawMessage{
	json.RawMessage(`{"type":"function","name":"get_weather","description":"Current weather for a city.","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}`),
	json.RawMessage(`{"type":"function","name":"add_numbers","description":"Add two numbers.","parameters":{"type":"object","properties":{"a":{"type":"number"},"b":{"type":"number"}},"required":["a","b"]}}`),
	json.RawMessage(`{"type":"function","name":"set_timer","description":"Start a countdown timer.","parameters":{"type":"object","properties":{"minutes":{"type":"number"}},"required":["minutes"]}}`),
	json.RawMessage(`{"type":"function","name":"convert_currency","description":"Convert an amount between currencies (ISO codes such as USD, EUR).","parameters":{"type":"object","properties":{"amount":{"type":"number"},"from":{"type":"string"},"to":{"type":"string"}},"required":["amount","from","to"]}}`),
}

Tools are the declarations sent with every task.

Functions

func Execute

func Execute(name string, arguments json.RawMessage) (json.RawMessage, error)

Execute runs a tool for real on its arguments. Unknown tools and unusable arguments return an error object, as a real backend would.

func Matches

func Matches(expected, actual map[string]any) bool

Matches reports whether every expected argument is present with an equivalent value: numbers numerically, cities and currencies normalised.

func Run

func Run(ctx context.Context, options Options) (bench.Result, error)

Run plays every task and scores it.

func Score

func Score(outcome *bench.TaskOutcome, task Task, transcript bench.Transcript)

Score reads one transcript against its task.

Types

type Options

type Options struct {
	Endpoint, Token, Model string
	Cell                   bench.Cell
	Limit                  int
	Timeout                time.Duration
	// ResultDelay is how long each tool takes. Zero selects two seconds.
	ResultDelay    time.Duration
	WaitConfigured bool
	Player         bool
	Progress       func(string)
}

Options configures one run.

type Task

type Task struct {
	ID             string         `json:"id"`
	Text           string         `json:"text"`
	Tool           string         `json:"tool"`
	Arguments      map[string]any `json:"arguments"`
	StaleArguments map[string]any `json:"stale_arguments,omitempty"`
	Spoken         []string       `json:"spoken"`
	Audio          string         `json:"audio"`
}

Task is one spoken request and what a correct agent does with it.

func Tasks

func Tasks() ([]Task, error)

Tasks returns the embedded fixture set.

Jump to

Keyboard shortcuts

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