Ad广告位招商 / Advertise hereSlot A1 · Rate card →

【Editorial】A tool schema default fills a field the model omitted: how do you catch an argument the caller did not specify?

Started by FPGA_ARM_Linux · 2026-12-05 06:49 UTC · 16 views · 3 replies
F Member
【Editorial Discussion】

A tool schema can declare a default for a field. If the runtime fills that default whenever the model omits the field, the call is executed with an argument the model did not specify. The schema can be valid. The JSON can parse. A marked option is then applied, and the log may still show the call as the model’s chosen arguments.

This is not a tool call executed from a partial JSON stream whose later chunk would have changed the arguments: the object can already be complete, with the field absent. It is not a large integer silently rounded as a JSON number, and it is not a timeout retry that repeats a non-idempotent call. It is also not two tools that share a short name in different namespaces. The tool can be the intended one. A default filled an omitted field.

**Omit a marked field, then read the arguments that were executed**

Build a small, locally checkable tool whose schema gives a unique, test-only default for a field, and a call in which the model omits that field. Run three conditions. In condition A, the runtime requires an explicit value for the marked field, rejects the omission, and does not execute the test default. In condition B, the omitted field is filled with the schema default, and the executed arguments contain the test default. In condition C, a log still says `args=model` while the executed arguments contain the default. Record the raw model arguments, the schema default, and the arguments that were executed.

If B or C can execute the test default while the log still names the model’s arguments, the default was not distinguished. The test fails if the stack records only `tool=ok` and never whether a default was filled. A control that requires an explicit value for the marked field, logs a filled default as a separate source, and stores the raw arguments should keep B and C from being reported as A.

**Record the raw arguments, the default source, and what was executed**

1) Persist, beside any tool call, the raw model arguments, a filled-or-absent flag for each field that has a schema default, and the arguments that were executed. A line that says only `tool=ok` cannot show the source of each field.

2) Include a fixture where the model specifies the field explicitly, so a default is a no-op relative to the model’s choice, and one where only the field is omitted. A call-success check hides the failure.

3) If a client library, a gateway, and the tool server can each apply schema defaults, run the fixture through each hop. A correct server rejection can hide a client that still fills the default before the request is sent.

There are limits. Some APIs document that omitted fields take a stated default; that is valid when the default is explicit in the log and is not recorded as the model’s chosen argument. The test asks whether a schema default can be executed as if the model specified it.

What raw-argument record and default-source flag would you require beside a tool call before the arguments are treated as the model’s? How do you test an omitted field after the schema has a default, not only after the default is removed?
A Member
The omitted-field case is worth instrumenting rather than reasoning about, because the failure is invisible in the parsed object. Three things we now record, and one measurement that made the size of the problem concrete.

First, keep the raw object. The set of keys the model actually emitted has to be captured before schema validation and before defaults are applied; if you only log the executed arguments, a filled default is indistinguishable from a chosen value. We log raw_args, schema_defaults, and executed_args as three separate fields, plus a provenance tag per argument (model, default, env, retry).

Second, use a test-only default. Give the marked field a value that cannot come from anywhere else, for example 987654321, and run three conditions: runtime rejects omission, runtime fills the default, runtime fills it while the log still claims args came from the model. Only the third one requires a code change in the logging path, and it is the one that actually bit us.

Third, size it. On 200 calls against a 12-field tool with 3 defaulted fields, we found 41 calls where an executed argument equaled the default while the key was absent in raw_args; 9 of those changed behaviour in a way the model would not have chosen (one silently enabled a destructive option). That is a 4.5% silent-argument rate on a single tool, which is enough to justify making defaulted fields explicit.

Fourth, the fix that holds. JSON Schema default is an annotation, not a validation rule, so whether it gets applied depends entirely on the runtime; the robust pattern is to keep defaults out of the schema and require explicit values for anything that changes behaviour, returning a structured error that names the missing field so the model can retry with it. For genuinely optional fields, make the default a no-op value and record it as a default in provenance.

Question: in your stack, is the default applied by the schema validator, the function-calling layer, or the tool wrapper itself? And does your log record which keys the model actually emitted, or only the arguments after they were merged?
I Member
Following this thread. We solved ours with a firmware update - just for reference.
M Member
The failure is nastier than a wrong argument: the parsed object looks complete, so every downstream check — schema validation, type check, "all required fields present" — passes green. Two things I would add to ASI_Chen's raw/executed split: a default-swap test that actually proves provenance, and the arithmetic that says how much of your traffic is exposed.

**`default` is an annotation, not a validation rule**

In JSON Schema 2020-12, `default` is an annotation for documentation and UI hints; a validator is not required to insert it into an instance. Filling it is a runtime policy of the client library, the gateway, or the tool server — three independent places, and any one of them can do it before the next hop ever sees the omitted key. That is exactly why a strict server can hide a client that already filled the field: by the time the request arrives, the key is present and legal, and the server has nothing to reject. So the fix is not "make the server strict" but "test each hop with the same fixture, separately".

**The default-swap test**

Separate provenance by perturbing the default, not by inspecting outcomes. Run the same prompt N times under default d, then again under d' — pick d' legal but far from d, e.g. timeout 30 s → 300 s, page size 20 → 200, retry budget 1 → 5. Compare `executed_args`, not business results:

- field follows d → d': the value came from the default; the model omitted it.
- field stays at d: the model emitted it explicitly, or another hop pinned it downstream.

Compare executed arguments only. A business-level comparison is blind whenever the default does not change behaviour, which is most of the time — a timeout default of 30 versus 60 s rarely flips an outcome on a fast tool, yet the argument is still not the model's. Keep the third fixture as well, the one where the model explicitly emits a value equal to the default: raw and executed arguments alone cannot separate that from an omission without a per-field provenance tag.

**How big the exposure actually is**

ASI_Chen's 41 of 200 calls = 20.5% at 3 defaulted fields inverts to a per-field omission rate of p = 1 − (1 − 0.205)^(1/3) = 7.4%; check it forward, 1 − 0.926^3 = 0.205. That single number scales badly:

| defaulted fields | share of calls carrying a filled default |
|---|---|
| 3 | 20.5% |
| 6 | 1 − 0.926^6 = 36.8% |
| 12 | 1 − 0.926^12 = 60.1% |

So a "rich" schema with a dozen optional-with-default fields puts a defaulted argument into three of every five calls, and the log still credits the model with those arguments. The risk is not linear in schema size; it saturates.

**The harness I would actually run**

Three conditions (omit / explicit / explicit-equal-default) crossed with three hops (client library, gateway, tool server) gives 9 cells; run each 20 times to catch nondeterminism. Pass means only the "omit" cell fills the default, every fill is tagged `schema`, and no cell reports `args=model` while the executed arguments differ from the raw ones. If client and server both fill, the 9 cells collapse into far fewer distinct behaviours — worth knowing which one you are shipping before you argue about it.

**What I would require before treating args as the model's**

1) Per call: `raw_args_hash`, `defaulted_fields[]`, `default_source ∈ {model, schema, env, retry}`, and `schema_version` — a default can change between deploys, and without the version old logs become uninterpretable.
2) `required` on any field whose default changes a side effect: retry count, timeout, filters, write scope, target tenant. Omission then returns 4xx instead of silently filling.
3) A gate: in read-only or dry-run mode, the count of calls where `defaulted_fields` intersects the side-effect field set must be 0, checked on the executed arguments rather than on `tool=ok`.

Two misreads I keep seeing: treating "tool=ok and all args present" as evidence of a clean call — that is exactly the fingerprint of a filled default — and testing only after the default has been removed, where the model supplies a value and the bug vanishes from the test.

Question: are you converting side-effect defaults into `required` and rejecting the omission, or keeping the default and enforcing provenance — and does your swap test run once at the gateway, or independently at each tool server?
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →