Separate schema annotations, versioned argument normalization and the exact effective payload sent to an adapter.
Omitted arguments still have operational meaning
A tool definition says that limit is an integer with a default of 20. The model sends an empty object. One component inserts 20, another accepts the empty object unchanged, and a third uses its own fallback of 100. Every component can appear reasonable in isolation while the resulting operation differs from what the reviewer understood. The problem is not malformed JSON. It is an unspecified transformation between proposed arguments and effective arguments.
JSON Schema's default is an annotation. The official reference explicitly says validation does not fill in missing values. A form generator or application may use it, but that is additional behavior owned by that application. Treating the annotation as an execution guarantee confuses documentation with normalization. An agent tool boundary should state who supplies defaults, when that happens and which version of the rule applies.
This guide uses a synthetic artifact-listing tool with two arguments: an integer result limit and a boolean indicating whether to include a calculated detail field. No external service is contacted. The worked example distinguishes omission, explicit values and explicit null. That distinction is useful even for read-only tools because it affects output size, cost and the amount of data returned to a model.
Define one effective argument contract
Keep the incoming proposal and normalized result as separate objects. The proposal records what the caller actually supplied. The effective object records what the adapter will execute. Attach a normalization version so an old saved proposal is not silently reinterpreted after the default limit changes. A retry should use the previously accepted effective arguments, provided the operation's separate authorization and freshness rules still permit it.
Decide whether null means a value, an instruction to clear something, or an error. In this example null is invalid for both fields. An omitted limit uses the contract's default, while an explicit zero is also invalid because the supported range begins at one. The boolean field preserves explicit false. A truthiness expression such as incoming.get('detail') or True would erase that choice and turn a valid request into a different request.
Reject unrecognized fields at the boundary. Silently ignoring limt and inserting a default for limit produces a plausible result while concealing a caller error. This is particularly troublesome with model-generated arguments: the tool seems to work, so the agent may never learn that its intended setting was not applied. Return a stable field-level diagnostic that permits a deliberate repair.
Normalize without mutating the proposal
The following original function implements a deliberately narrow contract with no third-party dependencies. It is not a general JSON Schema validator. The handwritten checks are the execution contract for this tiny tool; a larger service should use an appropriate validator and retain this explicit normalization stage around it. Python booleans are subclasses of integers, so the integer check uses exact type identity to reject True as a limit.
# Author: Sandeep Belgavi. Explicit, versioned tool argument normalization.
DEFAULTS = {1: {"limit": 20, "detail": False},
2: {"limit": 40, "detail": False}}
def normalize(proposal, version=1):
if not isinstance(proposal, dict):
raise ValueError("arguments must be an object")
if type(version) is not int or version not in DEFAULTS:
raise ValueError("unknown normalization version")
if set(proposal) - {"limit", "detail"}:
raise ValueError("unknown argument")
effective = dict(DEFAULTS[version])
effective.update(proposal)
if type(effective["limit"]) is not int or not 1 <= effective["limit"] <= 100:
raise ValueError("limit must be an integer in 1..100")
if type(effective["detail"]) is not bool:
raise ValueError("detail must be a boolean")
return {"normalization_version": version, "arguments": effective}
proposal = {"detail": False}
accepted = normalize(proposal)
assert accepted["arguments"] == {"limit": 20, "detail": False}
assert proposal == {"detail": False}
assert normalize({}, 2)["arguments"]["limit"] == 40Notice the precedence rule: defaults are copied first, then explicit values replace them, then the complete result is validated. A bad default is therefore rejected too. This matters during upgrades because an annotation may contain a value that does not satisfy its surrounding schema. Maintain tests for the default configuration itself, not only for malformed caller input.
Put approval after normalization
If a tool requires approval, show the effective arguments that will actually reach the adapter. The review surface should also distinguish supplied values from inserted values when the distinction helps the reviewer. A concise display might say that the caller supplied detail=false, while contract version 1 supplied limit=20. The approval receipt binds to the effective payload and contract revision, not merely to the raw empty object.
Do not normalize again after approval using whatever defaults happen to be current. That creates a time-dependent meaning for the same approved proposal. Persist the effective representation, or reconstruct it using the pinned normalization version and compare it with the approved representation. An adapter that adds further hidden defaults undermines this boundary; either move those rules into the contract or expose them explicitly in the receipt.
This ordering does not grant permission by itself. Validation establishes a supported shape, normalization establishes explicit meaning, and authorization establishes whether the actor may request that meaning. These are different checks with different failure reasons. A default that selects a broader resource scope still needs authorization even when the caller omitted the field and the schema describes the default as convenient.
Keep schemas and adapters in agreement
Generate the tool's public schema and the adapter's defaults from one versioned contract where practical. If they are maintained separately, add a consistency check that compares default values, numeric bounds, required fields and nullability. Avoid silently applying a library's coercion options in one path while another path uses strict validation. The string "20" and the number 20 should not change meaning depending on which transport invoked the tool.
Nested objects complicate copying and precedence. A shallow merge can replace an entire nested object, while a recursive merge can preserve fields the caller intended to omit or clear. Choose and document one rule. The example avoids nesting on purpose; extending it requires tests for nested omission, explicit empty objects and null. Do not present a generic recursive merge as universally correct for tool arguments.
Also separate provider-facing schema adaptation from local semantics. A model API may support only part of a schema dialect. That affects what constraints can be communicated to the model, but it must not weaken the local execution gate. The model's structured output remains an input to normalization and validation, even if the provider reports that it complied with the schema it received.
Migrate existing tools without changing old requests
First inventory every location that supplies a fallback: schema annotations, client wrappers, endpoint handlers and adapter libraries. Pick one owner for effective defaults and make other layers pass explicit values. During migration, log the old and new effective arguments on synthetic requests. Differences should be reviewed as behavior changes, including apparently harmless changes to page size or detail verbosity.
Next assign a normalization version to newly accepted calls. Keep old persisted calls associated with their original effective arguments. If a security or compatibility change makes an old default unacceptable, reject the old request with a clear migration requirement rather than silently rewriting it. A refusal is observable; an unnoticed expansion in tool scope is much harder to diagnose.
Test the distinctions that truthiness hides
The expected matrix includes omission, explicit false, explicit zero, null, a numeric string, a boolean supplied as an integer and a misspelled field. Assert the result or refusal for each case. Verify that the proposal object is unchanged after both success and failure. Then change the default in version 2 and confirm that replaying a version-1 request still produces the version-1 effective payload.
For an approved operation, test that the serialized effective arguments shown to the reviewer equal those delivered to the adapter. A test that only validates the schema misses this integration boundary. The offline example does not claim to exercise any provider's structured-output implementation. It demonstrates a deterministic contract that can be tested without spending tokens or relying on the model to generate the exact malformed input of interest.
Defaults are valuable when they reduce repetitive input without concealing consequential choices. They become dangerous when their owner and timing are implicit. Keep them explicit, versioned and visible at the point where a proposed tool call becomes an executable request. For a fixed internal workflow, simply passing every argument directly may be the clearest design of all.
Run the example yourself
The synthetic fixtures, expected output and tests behind this guide are in the companion code on GitHub; its README lists the prerequisites, exact commands, expected output and limits.