fix(translator): prevent doubled tool args in OpenAI-to-Claude - #5828
Merged
Merged
Conversation
Two one-line guards in the OpenAI<->Claude translators: - claude-to-openai.ts: a Claude tool_use block whose `input` is already a JSON-encoded string was re-run through JSON.stringify, double-encoding the payload. Now a string input is passed through verbatim. - openai-to-claude.ts: a duplicate finish_reason chunk (some OpenAI-compatible upstreams resend the terminal chunk) re-ran the entire finish block, emitting duplicate content_block_stop / message_delta / message_stop events. The guard now only runs the finish block once per stream via `state.finishReason`. Co-authored-by: Vishal Raj V <vishalrajv3@gmail.com> Inspired-by: decolua/9router#2279
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jul 2, 2026
Merged
5 tasks done
This was referenced Aug 28, 2026
tkgo11
pushed a commit
to tkgo11/OmniRoute
that referenced
this pull request
Sep 23, 2026
…souzapw#5828) Integrated into release/v3.8.43
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.
Thanks to @vishalrajv for the original implementation.
Two one-line fixes in the OpenAI<->Claude translators:
claude-to-openai.ts(request side): a Claudetool_useblock whoseinputis already a JSON-encoded string was re-run throughJSON.stringify, double-encoding the payload before it reached the OpenAI-compatible upstream. A stringinputis now passed through verbatim instead.openai-to-claude.ts(response side): a duplicatefinish_reasonchunk (some OpenAI-compatible upstreams resend the terminal chunk with an otherwise-empty delta) re-ran the entire finish block, emitting duplicatecontent_block_stop/message_delta/message_stopevents downstream. The finish block now only runs once per stream, guarded bystate.finishReason.Test plan
tests/unit/translator-claude-to-openai.test.ts(string tool_use input passthrough) andtests/unit/translator-resp-openai-to-claude.test.ts(duplicate finish_reason chunk emits finish events exactly once).node --import tsx/esm --test tests/unit/translator-claude-to-openai.test.ts tests/unit/translator-resp-openai-to-claude.test.ts— 23/23 passing.npm run typecheck:core— clean.