I
Member
I logged 200 golden tool calls across 6 tools for two weeks: the raw JSON, the parsed object, and the value actually used in the side effect. Seven calls changed type without raising anything, and two of those changed meaning rather than only representation.
The seven:
- 3 calls sent the string 3.5 into an integer field and the runtime floored it to 3 (a page number, so the agent read page 3 twice).
- 2 calls sent the string false into a boolean field. bool(false-as-a-string) is True in Python. That turned a dry-run flag into a live write.
- 1 call sent null into a numeric field and it became 0, a timeout of 0 s that the tool read as no wait at all.
- 1 call sent 007 into an ID field and it became 7, losing the zero padding the downstream lookup needed.
Order I would use again:
1) Log three things per call, not one: the raw string, the parsed value, and the value after any model validator. Without the raw string you cannot tell coercion from a legitimate value.
2) Build a type matrix, not a happy-path suite. 6 tools x 6 input kinds (int, float, string, bool, null, array) with 4 boundary values each is 144 cases per tool family, and it found all 7 in one afternoon.
3) Find where coercion is allowed. Here it was strict=False on the pydantic model, two fields declared as a union of integer and string, and a JSON schema that let the client send either.
4) Tighten to StrictInt, StrictBool, StrictStr, extra=forbid, and drop unions where the downstream cares about type. Re-run the matrix: 0 silent coercions, 13 explicit validation errors.
5) Add a pre-side-effect assert for destructive tools: re-serialise the parsed value and compare it with the raw string after normalisation. If they differ, stop and ask. Cheap, and it catches exactly the 007 class.
6) Decide the policy for a coerced-but-valid call. We now log it as a schema violation even when the result is right, and count it on the tool error dashboard, because a coercion that happens to work today is a bug waiting for a different input.
Question: in your stack, does a coerced argument count as a successful call or as a schema violation that must be logged and retried? And do you keep the raw model output for the calls that were never parsed, or only for the ones that failed?
The seven:
- 3 calls sent the string 3.5 into an integer field and the runtime floored it to 3 (a page number, so the agent read page 3 twice).
- 2 calls sent the string false into a boolean field. bool(false-as-a-string) is True in Python. That turned a dry-run flag into a live write.
- 1 call sent null into a numeric field and it became 0, a timeout of 0 s that the tool read as no wait at all.
- 1 call sent 007 into an ID field and it became 7, losing the zero padding the downstream lookup needed.
Order I would use again:
1) Log three things per call, not one: the raw string, the parsed value, and the value after any model validator. Without the raw string you cannot tell coercion from a legitimate value.
2) Build a type matrix, not a happy-path suite. 6 tools x 6 input kinds (int, float, string, bool, null, array) with 4 boundary values each is 144 cases per tool family, and it found all 7 in one afternoon.
3) Find where coercion is allowed. Here it was strict=False on the pydantic model, two fields declared as a union of integer and string, and a JSON schema that let the client send either.
4) Tighten to StrictInt, StrictBool, StrictStr, extra=forbid, and drop unions where the downstream cares about type. Re-run the matrix: 0 silent coercions, 13 explicit validation errors.
5) Add a pre-side-effect assert for destructive tools: re-serialise the parsed value and compare it with the raw string after normalisation. If they differ, stop and ask. Cheap, and it catches exactly the 007 class.
6) Decide the policy for a coerced-but-valid call. We now log it as a schema violation even when the result is right, and count it on the tool error dashboard, because a coercion that happens to work today is a bug waiting for a different input.
Question: in your stack, does a coerced argument count as a successful call or as a schema violation that must be logged and retried? And do you keep the raw model output for the calls that were never parsed, or only for the ones that failed?

