Skip to content

Commit 16e559e

Browse files
contextablemarkjoarclaude
authored
Validate 1332 (#1380) (#1381)
* Validate 1332 (#1380) * fix(adk-middleware): "SecuritySchemeType is not JSON serializable" this solves the issue of the built-in `adk_request_credentials` function call failing with ``` Traceback (most recent call last): File "/Users/joar.wandborg/git/myproject/.venv/lib/python3.14/site-packages/ag_ui_adk/adk_agent.py", line 2132, in _run_adk_in_background async for ag_ui_event in event_translator.translate_lro_function_calls( ...<5 lines>... logger.debug(f"Event queued: {type(ag_ui_event).__name__} (thread {input.thread_id}, queue size after: {event_queue.qsize()})") File "/Users/joar.wandborg/git/myproject/.venv/lib/python3.14/site-packages/ag_ui_adk/event_translator.py", line 763, in translate_lro_function_calls args_str = json.dumps(long_running_function_call.args) if isinstance(long_running_function_call.args, dict) else str(long_running_function_call.args) ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joar.wandborg/.local/share/uv/python/cpython-3.14.3-macos-aarch64-none/lib/python3.14/json/__init__.py", line 235, in dumps return _default_encoder.encode(obj) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/Users/joar.wandborg/.local/share/uv/python/cpython-3.14.3-macos-aarch64-none/lib/python3.14/json/encoder.py", line 202, in encode chunks = self.iterencode(o, _one_shot=True) File "/Users/joar.wandborg/.local/share/uv/python/cpython-3.14.3-macos-aarch64-none/lib/python3.14/json/encoder.py", line 263, in iterencode return _iterencode(o, 0) File "/Users/joar.wandborg/.local/share/uv/python/cpython-3.14.3-macos-aarch64-none/lib/python3.14/json/encoder.py", line 182, in default raise TypeError(f'Object of type {o.__class__.__name__} ' f'is not JSON serializable') TypeError: Object of type SecuritySchemeType is not JSON serializable ``` * refactor(adk-middleware): introduce serialize_tool_args for JSON serialization Added a new utility function `serialize_tool_args` to handle JSON serialization of tool-call arguments, addressing issues with non-standard types like Pydantic models and Enums. Updated relevant code in `client_proxy_tool`, `event_translator`, and `converters` to utilize this new function, ensuring consistent serialization across the application. Added comprehensive tests for the new serialization functionality. --------- Co-authored-by: Joar Wandborg <joar@wandborg.se> * docs(adk-middleware): add changelog entry for #1331 serialization fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Joar Wandborg <joar@wandborg.se> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e07e85b commit 16e559e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

integrations/adk-middleware/python/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- `translate_lro_function_calls()` now processes all LRO function calls in a single event, not just the first
3030
- `lro_emitted_ids_by_name` changed to `Dict[str, List[str]]` with positional (FIFO) matching in `_extract_lro_id_remap()` so every parallel call gets its own correct remap
3131

32+
- **FIX**: Use Pydantic serialization for tool-call args to handle non-stdlib-serializable types (#1331)
33+
- `json.dumps` on LRO function-call args (e.g. `adk_request_credential`) crashed with `TypeError: Object of type SecuritySchemeType is not JSON serializable` when args contained Pydantic models or Python Enums
34+
- Introduces a shared `serialize_tool_args()` helper using Pydantic's `TypeAdapter`, applied to all 5 call sites that previously used `json.dumps` on tool args
35+
- Thanks to **@joar** for this contribution!
36+
3237
- **FIX**: Strip JSON Schema meta-fields (`$schema`, `$id`, `$ref`, etc.) from tool parameters before passing to `google.genai.types.Schema.model_validate()` (#1349)
3338
- Frontend tools whose JSON Schema includes `$`-prefixed meta-fields (e.g. those generated by Zod/MCP) caused a Pydantic `ValidationError: Extra inputs are not permitted`, crashing the ADK runner silently
3439
- Adds recursive `_strip_json_schema_meta()` helper to `client_proxy_tool.py` that removes `$`-prefixed keys at all nesting levels before schema validation

0 commit comments

Comments
 (0)