mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(codex): use user-agent detection for Droid CLI compatibility
The previous merge used sourceFormat check which broke Cursor when it sends openai-responses format requests. Now uses user-agent detection: - Droid CLI (user-agent contains 'droid' or 'codex-cli') → passthrough - Other clients (Cursor, etc.) → translate to Chat Completions format This fixes the API translation for both clients. Co-authored-by: Hellodebasishsahu <itsyourboydevil@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
fafa77316b
commit
8c6e3b8b62
@@ -469,10 +469,11 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
|
|||||||
// Create transform stream with logger for streaming response
|
// Create transform stream with logger for streaming response
|
||||||
let transformStream;
|
let transformStream;
|
||||||
// For Codex provider, translate response from openai-responses to openai (Chat Completions) format
|
// For Codex provider, translate response from openai-responses to openai (Chat Completions) format
|
||||||
// UNLESS client originally sent in openai-responses format (like Droid CLI) - they expect same format back
|
// UNLESS client is Droid CLI which expects openai-responses format back
|
||||||
const needsCodexTranslation = provider === 'codex'
|
const isDroidCLI = userAgent?.toLowerCase().includes('droid') || userAgent?.toLowerCase().includes('codex-cli');
|
||||||
&& targetFormat === 'openai-responses'
|
const needsCodexTranslation = provider === 'codex'
|
||||||
&& sourceFormat !== 'openai-responses';
|
&& targetFormat === 'openai-responses'
|
||||||
|
&& !isDroidCLI;
|
||||||
|
|
||||||
if (needsCodexTranslation) {
|
if (needsCodexTranslation) {
|
||||||
// Codex returns openai-responses, translate to openai (Chat Completions) that clients expect
|
// Codex returns openai-responses, translate to openai (Chat Completions) that clients expect
|
||||||
|
|||||||
Reference in New Issue
Block a user