mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 16:29:42 +01:00
Failed native runs now report the runner's recorded turn-failure code instead of the generic unclassified fallback, and the Sentry run-failure fingerprint includes runner:<code>. Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.7 KiB
TypeScript
31 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { explainNativeTurnFailure, NATIVE_RUN_FAILED_UNEXPLAINED } from "./native-run-failure-explanation.js";
|
|
|
|
describe("explainNativeTurnFailure", () => {
|
|
const explained = (provider: string, cause: string) => ({
|
|
errorCode: NATIVE_RUN_FAILED_UNEXPLAINED.errorCode,
|
|
error: `The ${provider} turn failed (${cause}). Inspect the run events for the last recorded step.`,
|
|
});
|
|
|
|
it("names a runner-issued failure code", () => {
|
|
expect(explainNativeTurnFailure({ provider: "opencode", category: "turn_failed", runnerFailureCode: "opencode_empty_response" }))
|
|
.toEqual(explained("OpenCode", "opencode_empty_response"));
|
|
expect(explainNativeTurnFailure({ provider: "codex", category: "turn_failed", codexErrorInfo: "other", runnerFailureCode: "turn_binding_mismatch" }))
|
|
.toEqual(explained("Codex", "turn_binding_mismatch"));
|
|
});
|
|
|
|
it("names a specific Codex error kind when no runner code was issued", () => {
|
|
expect(explainNativeTurnFailure({ provider: "codex", category: "turn_failed", codexErrorInfo: "usageLimitExceeded", httpStatus: 429 }))
|
|
.toEqual(explained("Codex", "usageLimitExceeded"));
|
|
});
|
|
|
|
it("leaves a failure without a specific cause unexplained", () => {
|
|
expect(explainNativeTurnFailure(null)).toBeNull();
|
|
expect(explainNativeTurnFailure({ provider: "opencode", category: "turn_failed" })).toBeNull();
|
|
expect(explainNativeTurnFailure({ provider: "opencode", category: "turn_failed", runnerFailureCode: "unrecognized" })).toBeNull();
|
|
for (const codexErrorInfo of ["absent", "unrecognized", "other"]) {
|
|
expect(explainNativeTurnFailure({ provider: "codex", category: "turn_failed", codexErrorInfo, runnerFailureCode: "unrecognized" })).toBeNull();
|
|
}
|
|
});
|
|
});
|