Harness

Argument limits

Bound tool arguments per tool and field, and tell the model what to fix when a value is out of range.

args checks arguments against rules you set per tool. A value out of bounds gets a guide with what to fix, so the model can correct the call instead of retrying it unchanged.

guards.args({  refund_invoice: { amount: { min: 1, max: 500 }, currency: { oneOf: ["USD", "EUR"] } },  send_email: (args) => (String(args.to).endsWith("@example.com") ? undefined : "Only send to example.com addresses."),});

The first argument maps tool names to either a map of field rules or a function. A function gets the arguments and returns a message when they are wrong (nothing when they are fine); the message becomes the guide. Tools without rules pass. The only other option is mode.

Field rules#

TypeScriptPython and RubyApplies toCheck
minminNumbers and numeric stringsValue at least this
maxmaxNumbers and numeric stringsValue at most this
maxLengthmax_lengthStringsLength at most this
patternpatternStringsMust match. TypeScript: a RegExp. Python: a regex string (searched). Ruby: a Regexp or string.
oneOfone_ofAny valueMust be one of the list

Fields that are missing or null are skipped. min and max also hold for numbers passed as strings ("900"). A field with min or max whose value is a string that does not read as a number ("900abc") gets <field> has to be a number., since the tool might still read it as 900.

Messages#

RuleMessage
maxamount can be at most 500.
minamount has to be at least 1.
maxLengthnote can be at most 200 characters.
patterninvoice_id isn't in the expected format.
oneOfcurrency has to be one of: USD, EUR.

Every refusal has reason invalid_args. The guard stops at the first broken rule.