Contents

ArgumentMatcher

The values that define how to validate a tool-call argument.

Declaration

enum ArgumentMatcher

Mentioned in

Overview

Use argument matchers to specify validation rules for tool-call arguments. You can require exact values, verify key presence, check ranges, match patterns, or use a language model for semantic matching.

For example:

let matchers: [ArgumentMatcher] = [
    .exact(argumentName: "city", value: "San Francisco"),
    .keyOnly(argumentName: "units"),
    .naturalLanguage(argumentName: "prompt", criteria: "A weather-related question")
]

Validation Strategy

Rules

Exact(argumentname:value:)

Value must equal the expected value exactly. Use for identifiers, enum values, and precise inputs.

Keyonly(argumentname:)

Argument must be present with any value. Use when you care that the model provides the parameter but any value is acceptable.

Oneof(argumentname:allowedvalues:)

Value must be one of the allowed options. Use for ambiguous prompts with multiple valid interpretations.

Range(argumentname:minimum:maximum:)

Numeric value must fall within bounds (inclusive). Use for quantities where a range is acceptable.

Pattern(argumentname:regex:)

String must match a regular expression. Use for structured formats: emails, dates, IDs.

Contains(argumentname:substring:)

String must contain a substring. Use when the argument references a concept but phrasing varies.

Hasprefix(argumentname:prefix:)

String must start with a prefix. Use for paths, URLs, or namespaced values.

Hassuffix(argumentname:suffix:)

String must end with a suffix. Use for file extensions or domain-specific endings.

Naturallanguage(argumentname:criteria:)

A language model judges whether the value satisfies the criteria. Use when correctness is subjective or hard to express with string operations, for example, validating that a query argument is “a weather-related question”.

Topics

Exact matching

Set and range matching

String matching

Semantic matching

Supporting types

See Also

Tool-call evaluation