anthropic.internal._anth_verbatim_subtree

(internal) Drop null-valued map entries, recursively. BAML serializes an unset optional field as an explicit `null`, which the Messages API rejects for several parameters; the typed request classes above therefore go through this on their way to the wire, which is exactly serde's `skip_serializing_if = "Option::is_none"` in the Rust builders this replaces.

Reference version

Signature

function anthropic.internal._anth_verbatim_subtree(key: string) -> bool

(internal) Drop null-valued map entries, recursively. BAML serializes an unset optional field as an explicit null, which the Messages API rejects for several parameters; the typed request classes above therefore go through this on their way to the wire, which is exactly serde's skip_serializing_if = "Option::is_none" in the Rust builders this replaces.

Nulls INSIDE arrays are preserved (a JSON Schema "enum": [null] survives), and the two OPAQUE subtrees below are copied verbatim. The passthrough merge — where null means "delete this key" — still runs AFTER this, on the already-pruned base.

input (a replayed tool call's arguments) and input_schema (a tool's JSON Schema) are user/model JSON whose keys are DATA, not request parameters: a null there means "the model answered null" / "default": null, not "unset option". Pruning them rewrote conversation history on replay — every optional tool parameter the model answered with null silently vanished from the replayed tool_use, and the generated schema types optionals as ["string","null"] and marks them required, so a null answer is the schema-conformant one.

Source:<builtin>/anthropic/ns_internal/messages.bamlbytes 82008300