pcbeingused333 opened a new pull request, #14122:
URL: https://github.com/apache/apisix/pull/14122

   ### Description
   
   With `ai-proxy` in front of an OpenAI-compatible backend, an 
Anthropic-protocol client (for example Claude Code) gets no `tool_use` block 
when the backend streams `tool_calls` deltas without an `index`. Some 
OpenAI-compatible backends do this (Gemini's OpenAI endpoint, Mistral). The 
streaming converter skipped every tool call delta whose `index` was `nil`, so 
the call was dropped without a log line and the agent never ran the tool.
   
   **Fix.** In `anthropic-messages-to-openai-chat.lua`, a tool call delta 
without `index` now gets a synthetic key:
   - a delta with a non-empty `id` or `function.name` opens a new tool call;
   - a delta with only `function.arguments` continues the previous index-less 
call.
   
   Deltas that carry an `index` are handled exactly as before.
   
   **Test.** `TEST 76` in `t/plugin/ai-proxy-anthropic.t` feeds three 
index-less calls (two complete in one chunk each, one split across two chunks) 
through `convert_sse_events` and checks the `content_block_start` names and 
indexes (`f@0,g@1,h@2`) and the concatenated `input_json_delta` arguments. 
Without the change the same input produces no `tool_use` block at all.
   
   #### Which issue(s) this PR fixes:
   None: found while reading the converter; no issue filed for it.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change (no 
user-facing option changes)
   - [x] I have verified that this change is backward compatible (deltas with 
an `index` take the same path as before)
   
   This change was prepared with AI assistance (Claude Code).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to