fix(antigravity): don't inject default maxOutputTokens when client omits max_tokens

Real Antigravity client does not send maxOutputTokens when the user
hasn't specified it — the Cloud Code server decides the output limit.
OmniRoute was incorrectly injecting a capped default from model specs,
which caused thinking models to return empty content with low limits.
This commit is contained in:
ivan_yakimkin
2026-05-08 11:05:26 +03:00
parent 31da6a09a1
commit eeb836d62a

View File

@@ -567,7 +567,17 @@ export function openaiToAntigravityRequest(model, body, stream, credentials = nu
}
const geminiCLI = openaiToGeminiCLIRequest(model, body, stream);
return wrapInCloudCodeEnvelope(model, geminiCLI, credentials, true);
const envelope = wrapInCloudCodeEnvelope(model, geminiCLI, credentials, true);
// Match real Antigravity client: don't send maxOutputTokens when the user
// hasn't explicitly specified max_tokens / max_completion_tokens.
// The Cloud Code server decides the output limit on its own.
const clientRequestedMaxTokens = body.max_tokens ?? body.max_completion_tokens;
if (clientRequestedMaxTokens === undefined && envelope.request?.generationConfig) {
delete envelope.request.generationConfig.maxOutputTokens;
}
return envelope;
}
// Register