From 4e181d30fa6fa6fa30fac2727c79dffd06ac5d5e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 26 Apr 2026 19:15:00 +0100 Subject: [PATCH] test(gateway): classify stream fallback as empty live response --- src/gateway/gateway-models.profiles.live.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gateway/gateway-models.profiles.live.test.ts b/src/gateway/gateway-models.profiles.live.test.ts index aafface6fa5..4f0d4359e8a 100644 --- a/src/gateway/gateway-models.profiles.live.test.ts +++ b/src/gateway/gateway-models.profiles.live.test.ts @@ -31,6 +31,7 @@ import { shouldSuppressBuiltInModel } from "../agents/model-suppression.js"; import { ensureOpenClawModelsJson } from "../agents/models-config.js"; import { isRateLimitErrorMessage } from "../agents/pi-embedded-helpers/errors.js"; import { discoverAuthStorage, discoverModels } from "../agents/pi-model-discovery.js"; +import { STREAM_ERROR_FALLBACK_TEXT } from "../agents/stream-message-shared.js"; import { clearRuntimeConfigSnapshot, loadConfig } from "../config/io.js"; import type { ModelsConfig, ModelProviderConfig, OpenClawConfig } from "../config/types.js"; import { isTruthyEnvValue } from "../infra/env.js"; @@ -736,6 +737,16 @@ describe("shouldSkipEmptyResponseForLiveModel", () => { ); }); +describe("isEmptyStreamText", () => { + it.each([ + { text: "request ended without sending any chunks", expected: true }, + { text: `not meaningful: ${STREAM_ERROR_FALLBACK_TEXT}`, expected: true }, + { text: "not meaningful: let me think", expected: false }, + ])("returns $expected for $text", ({ text, expected }) => { + expect(isEmptyStreamText(text)).toBe(expected); + }); +}); + describe("isPromptProbeMiss", () => { it.each([ { error: "not meaningful: let me think", expected: true }, @@ -763,7 +774,10 @@ function isMissingProfileError(error: string): boolean { } function isEmptyStreamText(text: string): boolean { - return text.includes("request ended without sending any chunks"); + return ( + text.includes("request ended without sending any chunks") || + text.includes(STREAM_ERROR_FALLBACK_TEXT) + ); } function buildAnthropicRefusalToken(): string {