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

toolcfg

package
v0.23.2 Latest Latest
Warning

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

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

Documentation

Overview

Package toolcfg checks a request's tools and tool choice against the rules the model providers enforce, so an adapter refuses a setup the provider would answer with a 400 before sending it, with an agent.ErrConfig that says what is wrong.

Index

Constants

This section is empty.

Variables

View Source
var (
	OpenAIName    = regexp.MustCompile(`^[a-zA-Z0-9_-]{1,64}$`)
	AnthropicName = regexp.MustCompile(`^[a-zA-Z0-9_-]{1,64}$`)
	GeminiName    = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_.:-]{0,63}$`)
)

OpenAIName and AnthropicName are the tool-name patterns OpenAI and Anthropic document. GeminiName is Gemini's: it also allows dots and colons, but must start with a letter or an underscore.

Functions

func Check

func Check(provider string, name *regexp.Regexp, req agent.Request) (send bool, err error)

Check validates req for provider, whose tool names must match name. Every tool name must match and be unique; a tool choice must have a known mode, and "required" or "tool" needs declared tools, "tool" naming one of them. send reports whether the adapter should send req.ToolChoice at all: "auto" or "none" with no tools declared is already met, and the providers reject a tool choice with no tools, so it is left out.

Types

This section is empty.

Jump to

Keyboard shortcuts

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