Repository navigation
fix(providers): unindexed streamed tool-call ids dedupe; parsed stream detection (Eve2-F7/F8) - #615
Merged
Merged
Conversation
…eat it without `index` (Eve2-F7)
The tool-call id rewrite keys a repeated streamed id by ${choice.index}:${call.index};
deltas that repeat id but omit index (the OpenAI-compatible / Gemini-proxy servers the
rewrite exists for) minted call_1_2, call_1_3, ... - one logical call became N phantom
calls with fragmented arguments. A delta's slot in tool_calls now stands in for the
missing index, so a repeated raw id maps back to its first assignment; distinct ids
still get distinct ids and indexed behavior is unchanged.
…tream` field (Eve2-F8) isStreamingRequest() regexed the raw request body for /"stream"\s*:\s*true/, so a nested field like providerOptions.gateway.stream:true made a non-streamed call look streamed and watchedResponse() rewrote its JSON reply into SSE the consumer cannot parse. The check now JSON.parses the body once and reads the top-level stream field; a malformed body is not a stream.
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two runtime fixes in
src/providers/providerFetch.tsfrom the eve2 audit (audit/eve2/FINDINGS-runtime-tools.md§7–§8), each with a regression test inproviderFetchWatch.test.tsand a CHANGELOG line.F7 —
uniqueToolCallIdsfragmented a streamed call whose deltas repeatidwithoutindexToolCallIds.assign()only recognized a repeated streamed id when it could key it by${choice.index}:${call.index}. Deltas that repeatidbut omitindex— exactly the quirky OpenAI-compatible / Gemini-proxy servers this rewrite exists for — each minted a fresh suffix: one logical call becamecall_1,call_1_2,call_1_3, … with the arguments JSON split across phantom calls.Fix: a delta call's slot in
tool_callsstands in for the missingindexin the dedupe key, so a repeated raw id at the same position maps back to its first assignment. Distinct ids still get distinct ids; indexed behavior is unchanged.Repro
audit/eve2/repro/streamToolCallIdRewrite.ts: before[ 'call_1', 'call_1_2', 'call_1_3' ]→ after[ 'call_1', 'call_1', 'call_1' ](indexed control unchanged).F8 —
isStreamingRequestregexed the raw bodyisStreamingRequest()matched/"stream"\s*:\s*true/against the entire serialized request body, so any nested flag (providerOptions.gateway.stream: true, tool arguments, gateway metadata) made a non-streamed call look streamed — andwatchedResponse()rewrote its JSON reply into SSE events the consumer cannot parse.Fix: parse the body once and read the top-level
streamfield; a malformed body is not a stream.Repro
audit/eve2/repro/streamRegexFalsePositive.ts: before — JSON completion rewritten todata: …SSE withcontent-type: text/event-stream→ after — JSON preserved.Verification
npx tsx).npx tsc --noEmit -p tsconfig.json— clean.npm run lint— clean.npx vitest run src/providers— 608 passed, 4 skipped (live tests); the two dist-dependent files needednpm run buildin the fresh worktree, which also passed.npm run api:check— all 20 reports up to date (no public API change).