From db129431464eacfb722cfe04b7f9f5c11fd3b212 Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Thu, 6 Aug 2026 08:44:36 +0800 Subject: [PATCH] fix(open-sse): populate empty message content when reasoning text is present on tool_calls finish (#9196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log --- open-sse/utils/stream.ts | 2 ++ src/app/api/providers/[id]/test/route.ts | 28 ++++++++++++++---------- src/lib/tokenHealthCheck.ts | 2 +- src/sse/services/auth.ts | 1 + tests/unit/sse-auth.test.ts | 10 +++++++++ 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/open-sse/utils/stream.ts b/open-sse/utils/stream.ts index 757ab15b3c..8857ad442b 100644 --- a/open-sse/utils/stream.ts +++ b/open-sse/utils/stream.ts @@ -2498,6 +2498,8 @@ export function createSSEStream(options: StreamOptions = {}) { console.warn( `[STREAM] Empty assistant response after tool_calls completion (${provider || "provider"}:${model || "unknown"}) — sessionId=${sessionId}` ); + } else if (passthroughHasToolCalls && !content.trim() && reasoning.trim()) { + message.content = ""; } const responseBody = { diff --git a/src/app/api/providers/[id]/test/route.ts b/src/app/api/providers/[id]/test/route.ts index 9cae225cf5..5e403829c3 100644 --- a/src/app/api/providers/[id]/test/route.ts +++ b/src/app/api/providers/[id]/test/route.ts @@ -15,6 +15,7 @@ import { getCliRuntimeStatus } from "@/shared/services/cliRuntime"; import { getAccessToken } from "@omniroute/open-sse/services/tokenRefresh.ts"; import { rotationGroupFor } from "@omniroute/open-sse/services/refreshSerializer.ts"; import { saveCallLog } from "@/lib/usageDb"; +import { shouldHideLogs } from "@/lib/tokenHealthCheck"; import { logProxyEvent } from "@/lib/proxyLogger"; import { runWithProxyContext } from "@omniroute/open-sse/utils/proxyFetch.ts"; import { isGitLabDirectAccessDisabled } from "@/lib/oauth/gitlab"; @@ -743,18 +744,21 @@ export async function testSingleConnection(connectionId: string, validationModel // Log to Logger tab (call_logs table) try { - saveCallLog({ - method: "POST", - path: "/api/providers/test", - status: result.valid ? 200 : result.statusCode || 401, - model: "connection-test", - provider, - connectionId, - duration: latencyMs, - error: result.valid ? null : result.error || null, - sourceFormat: "test", - targetFormat: "test", - }).catch(() => {}); + const hideLogs = await shouldHideLogs(); + if (!hideLogs) { + saveCallLog({ + method: "POST", + path: "/api/providers/test", + status: result.valid ? 200 : result.statusCode || 401, + model: "connection-test", + provider, + connectionId, + duration: latencyMs, + error: result.valid ? null : result.error || null, + sourceFormat: "test", + targetFormat: "test", + }).catch(() => {}); + } } catch {} // Log to Proxy tab (proxy_logs table) diff --git a/src/lib/tokenHealthCheck.ts b/src/lib/tokenHealthCheck.ts index b8c57d1747..6b4475dd21 100644 --- a/src/lib/tokenHealthCheck.ts +++ b/src/lib/tokenHealthCheck.ts @@ -275,7 +275,7 @@ let cacheTimestamp = 0; let pendingHideLogs: Promise | null = null; const CACHE_TTL = 30_000; // Cache settings for 30 seconds -async function shouldHideLogs(): Promise { +export async function shouldHideLogs(): Promise { if ( isEnvFlagEnabled("OMNIROUTE_HIDE_HEALTHCHECK_LOGS") || isBuildProcess() || diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.ts index 65d0578c5d..372445bb35 100644 --- a/src/sse/services/auth.ts +++ b/src/sse/services/auth.ts @@ -927,6 +927,7 @@ export { readHeaderValue, type AuthRequestHeaders } from "./headerReader.ts"; const PROVIDER_SEARCH_PAIRS: string[][] = [ ["nvidia", "nvidia_nim"], ["kimi-coding", "kimi-coding-apikey"], + ["antigravity", "agy"], ]; /** * Resolve provider aliases (e.g., nvidia -> nvidia_nim) for DB lookup diff --git a/tests/unit/sse-auth.test.ts b/tests/unit/sse-auth.test.ts index ccb0c5dc29..94b884c9bc 100644 --- a/tests/unit/sse-auth.test.ts +++ b/tests/unit/sse-auth.test.ts @@ -1096,6 +1096,16 @@ test("getProviderCredentials resolves the nvidia special alias pool", async () = assert.equal(selected.connectionId, connection.id); }); +test("getProviderCredentials resolves the antigravity / agy alias pool", async () => { + const connection = await seedConnection("agy", { + name: "antigravity-alias-connection", + }); + + const selected = await auth.getProviderCredentials("antigravity"); + + assert.equal(selected.connectionId, connection.id); +}); + test("getProviderCredentials exposes copilotToken when present in providerSpecificData", async () => { const connection = await seedConnection("codex", { authType: "oauth",