Skip to content

port(upstream): B1 translator correctness - #185

Merged
bloodf merged 7 commits into
devfrom
port/upstream-b1-translator
Jul 10, 2026
Merged

bloodf merged 7 commits into
devfrom
port/upstream-b1-translator

Conversation

@bloodf

@bloodf bloodf commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Port/feature work. See commit messages for details.

CortexOS and others added 7 commits July 10, 2026 20:44
Non-lossy salvageOrphanedToolResults folds orphan tool output into user text
(`[Tool result: ...]`) instead of dropping it, across messages[] (OpenAI role:tool,
Claude tool_result blocks) and contents[] (Gemini/Antigravity functionResponse).
Runs unconditionally in the request pipeline and after each compression stage
(RTK/Headroom/PXPIPE) with fixMissingToolResponses to restore the tool-pairing
invariant. Responses API function_call_output stays structurally stripped in
openai-responses.js. Removes the obsolete shouldStripOrphanedToolResults gate;
Gemini-family standalone functionResponse (no functionCall) is preserved.

Ported from decolua/9router#2237 @ a32bda9e44
Translator regression asserting the OpenAI->Claude response translator
deduplicates doubled JSON tool arguments (same object emitted twice) into a
single parseable input_json_delta, and emits message_stop exactly once.

Logic (claudeFinishHandled finish guard + deduplicateDoubledJson) already
present in dev; this locks the behavior.

Ported from decolua/9router#2279 @ 1c9ad466ed
Translator regression asserting a Claude->OpenAI stream surfaces reasoning via
the reasoning channel and never emits literal <think>/</think> text in
delta.content. Logic (reasoningDelta channel, no think-tag content deltas)
already present in dev; this locks the behavior.

Ported from decolua/9router#2190 @ dc417f9b3f
Translator regression asserting Responses->Chat translation drops
client_metadata/background/truncation (Responses-API-only fields rejected by
third-party chat providers with HTTP 400) while the plain OPENAI->OPENAI path
preserves them (negative control). Logic already present in dev; locks behavior.

Ported from decolua/9router#2318 @ edb20e143d
restore the Gemini-family (gemini/gemini-cli/antigravity/vertex) guard
around salvageOrphanedToolResults in the translateRequest pipeline. the
body still carries native contents[] at that point; salvage keys known
functionCalls globally and rewrites any functionResponse whose id is not
in that set into '[Tool result: ...]' text, dropping legitimate tool
results before gemini->openai conversion can read them.

fixes CI run 29122517702 (tests/unit/gemini-to-openai-function-response).
@bloodf
bloodf merged commit 187fe67 into dev Jul 10, 2026
3 checks passed
@bloodf
bloodf deleted the port/upstream-b1-translator branch July 17, 2026 02:51
@bloodf bloodf mentioned this pull request Jul 20, 2026
7 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant