A model's tool arguments are normalized against the tool's own schema
Models hand back arguments that are nearly right: a JSON array as a string, a value escaped twice. Normalization repairs only the cases the tool's own schema can vouch for, and leaves the rest for validation to report honestly.
The rule
- Before a tool is invoked, the arguments a model supplied MUST be reconciled with the tool's declared input schema.
- A string argument MUST be decoded as JSON when three conditions hold, and MUST NOT be decoded otherwise.
- The conditions are that the schema declares that parameter
arrayorobject, that the string parses as JSON, and that the parsed shape matches what was declared: an array forarray, a map forobject. - A parameter declared
stringMUST NOT be decoded. - A parsed value of the wrong shape MUST NOT be substituted.
- An argument that fails any of the three MUST be passed through unmodified.
- Independently, every string leaf of an argument MUST have its HTML character references decoded, repeated until the value stops changing, so that a doubly-escaped value resolves fully rather than one level short.
- An implementation MAY bound the number of passes.
- Keys MUST NOT be modified.
- Text containing no character reference MUST be returned unchanged.
What it means
The two repairs are independent and run on different things. JSON-string
decoding looks only at whether the tool's own schema declares that
parameter array or object, and only fires when the parsed result
actually has that shape — a string that parses as JSON but produces the
wrong shape (an object where the schema declares an array) is left exactly
as sent, never coerced or substituted. Entity decoding, by contrast, runs on
every string leaf regardless of what the schema declares, repeating until
the value stops changing, so a doubly-escaped value resolves fully rather
than stopping one level short. Keys are never touched by either repair.
Example
A title argument arrives HTML-escaped twice over:
{ "title": "Ember & Oak" }{ "title": "Ember & Oak" }An object literal sent for a parameter the schema declares array is left
untouched rather than substituted into the wrong shape:
{ "ops": "{\"op\":\"add\"}" }Why
Recorded under OPEN-25.
References
Normative: incorporated into this rule
- HTML StandardNamed character referencesThe set of named references a string argument is decoded against.