Skip to content

skip all modifications for same-format requests (lossless passthrough)#468

Draft
kwanLeeFrmVi wants to merge 1 commit intodecolua:masterfrom
kwanLeeFrmVi:feature/lossless-pass-through-if-same-provider
Draft

skip all modifications for same-format requests (lossless passthrough)#468
kwanLeeFrmVi wants to merge 1 commit intodecolua:masterfrom
kwanLeeFrmVi:feature/lossless-pass-through-if-same-provider

Conversation

@kwanLeeFrmVi
Copy link
Copy Markdown
Contributor

Move normalizeThinkingConfig, ensureToolCallIds, fixMissingToolResponses, filterToOpenAIFormat, and prepareClaudeRequest inside !isSameFormat guard to ensure Claude→Claude and OpenAI→OpenAI requests are truly lossless without any normalization or modification steps.

…sless passthrough)

Move normalizeThinkingConfig, ensureToolCallIds, fixMissingToolResponses, filterToOpenAIFormat, and prepareClaudeRequest inside !isSameFormat guard to ensure Claude→Claude and OpenAI→OpenAI requests are truly lossless without any normalization or modification steps.
@decolua
Copy link
Copy Markdown
Owner

decolua commented Apr 4, 2026

Hey @kwanLeeFrmVi — thank you so much for this PR! Really appreciate the idea of skipping unnecessary transformations for same-format requests. Sorry for the delayed response, things have been quite busy on our end.

We loved the concept, but ended up going with a slightly different approach: instead of checking sourceFormat === targetFormat, we detect the CLI tool identity (Claude Code, Gemini CLI, Antigravity, Codex) from request headers and pair it with the target provider. If they are a native pair, the request body is passed through losslessly — only the model name and Bearer token are swapped.

The reason: different providers have different request signatures and special fields. A blanket same-format check could cause issues when users switch providers mid-session — provider-specific fields from one provider might leak into requests for another, resulting in errors or unexpected behavior.

Thanks again for the contribution — it sparked a solid improvement! 🙏

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.

2 participants