49
50
#### Dynamic keys apply only where they should
51
52
-Where a schema declares `patternProperties` or a schema-valued `additionalProperties`, each key is now validated against exactly the schemas that claim it. Previously a key could pass by satisfying an unrelated pattern instead of its own.
52
+Where a schema declares `patternProperties` or a schema-valued `additionalProperties`, each key is now validated against exactly the schemas that claim it. In TypeScript a key could previously pass by satisfying an unrelated pattern instead of its own. In Python neither keyword was read at all, so dynamic keys were never validated.
53
54
- Every matching `patternProperties` entry validates its key.
55
- `additionalProperties` applies only to keys that no declared property and no pattern matches.
57
58
Root-level `patternProperties` and boolean- or schema-valued `additionalProperties` also survive tool schema parsing; they were previously dropped before any converter could see them.
59
60
+<Callout type="warn">
61
+**Behavior change**
62
+
63
+Because the Python converter read neither keyword, an object that declared no properties became an empty Pydantic model: every dynamic key was dropped and the call ran without it. Those keys are now validated — at the root, nested under a declared property, and inside array items — and preserved when they pass.
64
+
65
+</Callout>
66
+
67
+**Before:**
68
+
69
+```python
70
+# `metadata` is {"type": "object"} with "patternProperties": {"^count_": {"type": "integer"}}
71
+wrapped.run({"metadata": {"count_a": "not-an-integer"}})
72
+# The tool executed with {"metadata": {}} - every dynamic key was dropped in silence
73
+```
74
+
75
+**After:**
76
+
77
+```python
78
+wrapped.run({"metadata": {"count_a": "not-an-integer"}})
79
+# Raises ValidationError before execution
80
+
81
+wrapped.run({"metadata": {"count_a": 3}})
82
+# The tool executes with {"metadata": {"count_a": 3}} intact
83
+```
84
+
85
In Python, an invalid `patternProperties` or schema-valued `additionalProperties` schema now raises while the tool is wrapped instead of being ignored. This includes an external, anchored, or unresolvable `$ref`, a `patternProperties` key that is not a valid regular expression, or a dynamic-key subschema that is not valid Draft 7. A `$ref` in these schemas must be a local JSON Pointer such as `#/properties/foo`. The rule is transitive: a local pointer whose target carries a non-local reference raises too. A `$ref`-shaped value under `const`, `default`, `enum`, or `examples` is instance data rather than a reference, and is left alone.
86
87
### Behavior Change for Python Agentic Providers
139
140
Accepting and preserving free-form object content is backward compatible: payloads that previously failed now succeed, and payloads that previously arrived empty now arrive complete.
141
117
-The two unknown-key rejections described above (Python agentic providers and the Claude Agent SDK provider) are the behavior changes at call time. Tools whose schemas set `additionalProperties: true`, or whose objects declare no properties, are unaffected.
142
+The two unknown-key rejections described above (Python agentic providers and the Claude Agent SDK provider) are two of the three behavior changes at call time. The third is [Python dynamic-key validation](#dynamic-keys-apply-only-where-they-should): a key that used to be dropped in silence now raises a `ValidationError` when it does not match the `patternProperties` or `additionalProperties` schema that claims it.
143
+
144
+`additionalProperties: true` still opts an object out of unknown-key rejection, and so does declaring no properties. Neither opts out of the third change: if the object also carries `patternProperties` or a schema-valued `additionalProperties`, its keys are validated against those schemas. Objects with no dynamic-key constraints at all are unaffected.
145
146
The one remaining change happens earlier, while a Python tool is wrapped: an invalid dynamic-key schema now raises instead of being ignored. Only tools whose `patternProperties` or schema-valued `additionalProperties` contain an invalid reference, regular expression, or Draft 7 subschema are affected.