Skip to content

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

Normative: this is the rule
  1. Before a tool is invoked, the arguments a model supplied MUST be reconciled with the tool's declared input schema.
  2. A string argument MUST be decoded as JSON when three conditions hold, and MUST NOT be decoded otherwise.
  3. The conditions are that the schema declares that parameter array or object, that the string parses as JSON, and that the parsed shape matches what was declared: an array for array, a map for object.
  4. A parameter declared string MUST NOT be decoded.
  5. A parsed value of the wrong shape MUST NOT be substituted.
  6. An argument that fails any of the three MUST be passed through unmodified.
  7. 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.
  8. An implementation MAY bound the number of passes.
  9. Keys MUST NOT be modified.
  10. 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:

A doubly-escaped title argumentsent
{ "title": "Ember & Oak" }
What reaches the tooldecoded
{ "title": "Ember & Oak" }

An object literal sent for a parameter the schema declares array is left untouched rather than substituted into the wrong shape:

An object literal where the schema declares an arraysent
{ "ops": "{\"op\":\"add\"}" }

Why

Recorded under OPEN-25.

References

Normative: incorporated into this rule

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · RT-TOOL-8 · changed in spec 1.0