mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 04:23:03 +00:00
Classify provider conversation-state rejections and return a clear message-channel error instead of auto-resetting or falling back to a generic runner failure. Local validation: - pnpm docs:list - pnpm build - pnpm check - node scripts/run-vitest.mjs src/auto-reply/reply/provider-request-error-classifier.test.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/dispatch-from-config.test.ts - node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts Co-authored-by: dutifulbob <261991368+dutifulbob@users.noreply.github.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
classifyProviderRequestError,
|
|
PROVIDER_CONVERSATION_STATE_ERROR_USER_MESSAGE,
|
|
} from "./provider-request-error-classifier.js";
|
|
|
|
describe("provider request error classifier", () => {
|
|
it.each([
|
|
[
|
|
"OpenAI missing custom tool output",
|
|
"Custom tool call output is missing for call id: call_live_123.",
|
|
],
|
|
[
|
|
"Bedrock tool result count mismatch",
|
|
"The number of toolResult blocks at messages.186.content exceeds the number of toolUse blocks of previous turn.",
|
|
],
|
|
[
|
|
"Gemini function-call ordering mismatch",
|
|
"400 Function call turn comes immediately after a user turn or after a function response turn.",
|
|
],
|
|
["generic role ordering mismatch", "400 Incorrect role information"],
|
|
[
|
|
"alternating role ordering mismatch",
|
|
"messages: roles must alternate between user and assistant",
|
|
],
|
|
])("classifies %s as provider conversation-state errors", (_label, message) => {
|
|
expect(classifyProviderRequestError(new Error(message))).toEqual({
|
|
code: "provider_conversation_state_error",
|
|
userMessage: PROVIDER_CONVERSATION_STATE_ERROR_USER_MESSAGE,
|
|
technicalMessage: message,
|
|
});
|
|
});
|
|
|
|
it("ignores unrelated provider errors", () => {
|
|
expect(classifyProviderRequestError(new Error("429: rate limit exceeded"))).toBeUndefined();
|
|
});
|
|
});
|