Skip to content

fix(agent): split concatenated parallel tool call arguments from Gemini OpenAI-compat endpoint (#62937) - #62972

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/62937-gemini-parallel-tool-calls
Closed

fix(agent): split concatenated parallel tool call arguments from Gemini OpenAI-compat endpoint (#62937)#62972
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/62937-gemini-parallel-tool-calls

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

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_calls entry. Google's OpenAI-compat layer does not increment tool_calls[].index for parallel calls, so the streaming assembler concatenates all argument fragments into one string. json.loads() rejects with "Extra data", and _repair_tool_call_arguments replaces everything with {}. Tools execute with empty arguments — silently doing nothing.

Changes

  1. agent/chat_completion_helpers.py: When json.loads fails with "Extra data" on tool call arguments, uses json.JSONDecoder().raw_decode to peel off each complete object and emit one mock_tool_call per object (with distinct _split_N ids)
  2. 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.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/gemini Google Gemini (AI Studio, Cloud Code) P2 Medium — degraded but workaround exists labels Jul 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Fix PR for #62937. This targets the Gemini OpenAI-compat chat_completions streaming path (raw_decode split + a new repair pass), which is a distinct code path from the closed native-adapter concatenated-JSON cluster (#25333/#25347/#36039/#33402) and the open native-adapter #54355 -- related, not a duplicate.

@teknium1

Copy link
Copy Markdown
Contributor

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 model-output-repair policy: Hermes does not add new repair or reconstruction passes for malformed model tool-call arguments.

  • agent/chat_completion_helpers.py:2319 does currently concatenate argument fragments for a repeated stream index, and :2362-2377 routes invalid JSON through repair handling.
  • PR commit 98ae9d57dc8c0318ec17c770bfb4c31e64190bb4 adds a JSONDecoder.raw_decode() loop that reconstructs multiple tool calls and a new sanitization repair pass that selects decoded content.
  • The standing policy rejects new parsing/reconstruction of malformed tool output, including concatenated/mangled tool-call JSON, even where the observed failure is real.

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 (model-output-repair). This is a design-direction decision, not a code-quality judgment — see the Contribution Rubric in AGENTS.md for what the project is looking for. If you believe this policy was misapplied to your change, comment here and a maintainer will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/gemini Google Gemini (AI Studio, Cloud Code) sweeper:not-planned Sweeper: closed per standing maintainer policy (design direction) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants