mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:00:43 +00:00
test(gateway): classify stream fallback as empty live response
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user