fix(agent): split concatenated parallel tool call arguments from Gemini OpenAI-compat endpoint (#62937) - #62972
Conversation
…ni OpenAI-compat endpoint (NousResearch#62937)
Fix PR for #62937. This targets the Gemini OpenAI-compat |
|
Thanks for isolating the Gemini OpenAI-compatible streaming path, and for documenting why it differs from the native-adapter reports linked in the discussion. This automated hermes-sweeper review is closing this as not planned because the proposed mechanism matches the standing
A provider-side correction that emits distinct OpenAI-compatible tool-call indices/entries is the appropriate direction. Closed as not-planned per standing maintainer policy ( |
Summary
When the configured provider is Gemini via its OpenAI-compatible endpoint, the model frequently emits multiple parallel function calls concatenated into a single
tool_callsentry. Google's OpenAI-compat layer does not incrementtool_calls[].indexfor parallel calls, so the streaming assembler concatenates all argument fragments into one string.json.loads()rejects with "Extra data", and_repair_tool_call_argumentsreplaces everything with{}. Tools execute with empty arguments — silently doing nothing.Changes
agent/chat_completion_helpers.py: Whenjson.loadsfails with "Extra data" on tool call arguments, usesjson.JSONDecoder().raw_decodeto peel off each complete object and emit onemock_tool_callper object (with distinct_split_Nids)agent/message_sanitization.py: Added Repair pass 5 — when payload contains ≥2 concatenated JSON objects, returns the first decoded object instead of{}Verification
99 tool_call/streaming/repair tests pass.