toolargs

package
v0.194.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0, MIT Imports: 4 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseSchema

func CloseSchema(schema json.RawMessage) json.RawMessage

CloseSchema returns the schema with additionalProperties:false so the model is told unknown keys are not accepted. An explicit value is preserved (an MCP tool or a free-form schema may deliberately allow extras). Malformed input is returned unchanged: the schema tests catch it, and a decode error must not silently reshape a tool contract at request time.

func DecodeStrictObject

func DecodeStrictObject(tool, args string, allowed ...string) (map[string]json.RawMessage, error)

DecodeStrictObject decodes a JSON object and rejects every key outside allowed. Tools that need numeric-string coercion decode the returned map, coerce, then unmarshal into their typed params — the strict check happens before any behavior is chosen.

func SchemaPropertyNames

func SchemaPropertyNames(schema json.RawMessage) ([]string, error)

SchemaPropertyNames returns the sorted top-level property names of a tool schema. An empty set is legitimate — a no-argument tool such as list_subagents has `"properties": {}` — and means every supplied key is unknown.

func StrictToolArgs

func StrictToolArgs(tool string, schema json.RawMessage, args string, out any) error

StrictToolArgs decodes args into out using the tool's own schema as the source of truth for the allowed keys: every top-level property is accepted, every other key is rejected with the allowed list. Tools with no arguments may pass an empty string.

Types

type UnknownArgumentError

type UnknownArgumentError struct {
	Tool      string
	Arguments []string
	Allowed   []string
}

UnknownArgumentError reports a tool call that named a key the tool does not accept. The model sees the allowed list so the next attempt can be right, instead of the typo silently changing behavior (the reason this exists: "backgroud": true ran a foreground dispatch).

func (*UnknownArgumentError) Error

func (e *UnknownArgumentError) Error() string

Jump to

Keyboard shortcuts

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