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
{{ message }}
Repository navigation
ApigeeLlm Chat Completions crashes on typed tool result values #8131
models[Component] This issue is related to model supportwip[Status] This issue is being worked on. Either there is a pending PR or is planned to be fixed
ApigeeLlm's Chat Completions adapter calls json.dumps directly on tool responses. A normal Python tool returning a date, datetime, Decimal, UUID, or Pydantic model therefore crashes before sending the next HTTP request. This affects both streaming and non-streaming requests.
Reproduction
Use an ApigeeLlm configured for an OpenAI-compatible Chat Completions endpoint with this tool:
When the model calls get_invoice, the result becomes a FunctionResponse successfully, but conversion to the next Chat Completions request raises TypeError: Object of type date is not JSON serializable in CompletionsHTTPClient._contents_to_messages.
Expected: send valid JSON with the date encoded as an ISO string and Decimal encoded without losing precision, consistent with ADK's typed model values. Ordinary JSON results should remain unchanged.
Environment and validation
Reproduced on main at 12aab4aaa, Python 3.12.10, Windows. A real InMemoryRunner and FunctionTool were exercised against a local HTTP server emitting OpenAI-compatible responses, for both NONE and SSE streaming. No live Apigee deployment or provider credentials were used.
This is separate from #8123, which affects the LiteLlm adapter. Apigee has its own serializer and raises rather than falling back to a Python repr. The proposed fix uses the already-installed Pydantic serializer only for values unsupported by the standard JSON encoder.
Prepared with AI assistance; reproduction and validation were executed locally.
@1aifanatic. Reproduced this on 2.14.1 and current main (also on 1.27.2) with a local fake endpoint: the get_invoice result fails at apigee_llm.py:850 before the second request goes out.
As a workaround I passed default=lambda o: to_jsonable_python(o, by_alias=False, bytes_mode='base64') to that json.dumps call. The tool message then came through as {"due": "2026-12-01", "total": "12.50"}, and plain dict results were unchanged.
Could you check that this matches what you see on your side, including SSE? It’s also worth trying a nested Pydantic model and bytes, since those take the base64 path.
Once it holds up in your testing, please take #8134 out of draft so it can go to review. It would be good to keep the options in line with the Gemma fix and #8125.
models[Component] This issue is related to model supportwip[Status] This issue is being worked on. Either there is a pending PR or is planned to be fixed
Activity
surajksharma07 commentedon Nov 18, 2026
@1aifanatic. Reproduced this on 2.14.1 and current main (also on 1.27.2) with a local fake endpoint: the get_invoice result fails at apigee_llm.py:850 before the second request goes out.
As a workaround I passed default=lambda o: to_jsonable_python(o, by_alias=False, bytes_mode='base64') to that json.dumps call. The tool message then came through as {"due": "2026-12-01", "total": "12.50"}, and plain dict results were unchanged.
Could you check that this matches what you see on your side, including SSE? It’s also worth trying a nested Pydantic model and bytes, since those take the base64 path.
Once it holds up in your testing, please take #8134 out of draft so it can go to review. It would be good to keep the options in line with the Gemma fix and #8125.
willie3838 commentedon Dec 3, 2026
Hey @1aifanatic thanks for contributing to this! An internal team will be taking over from here and your work will be credited.