You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(utils): Avoid double serialization of strings in safe_serialize (#5587)
When `serialize_item()` inside `safe_serialize()` already returns a
string
(for plain strings, callables, or objects with `__dict__`), the
subsequent
`json.dumps()` call wraps it in extra quotes with escaped characters.
For
example, a JSON string `'{"param": "value"}'` becomes
`'"{\\"param\\": \\"value\\"}"'`.
This was causing double-serialized tool arguments in pydantic-ai
integrations.
The fix skips `json.dumps` when `serialize_item` has already produced a
string, and adds tests covering plain strings, JSON strings, dicts,
callables, and objects.
Part of PY-2114
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments