Documentation
¶
Index ¶
- func CloseSchema(schema json.RawMessage) json.RawMessage
- func DecodeStrictObject(tool, args string, allowed ...string) (map[string]json.RawMessage, error)
- func SchemaPropertyNames(schema json.RawMessage) ([]string, error)
- func StrictToolArgs(tool string, schema json.RawMessage, args string, out any) error
- type UnknownArgumentError
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 ¶
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 ¶
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 ¶
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