mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-22 11:54:35 +01:00
fix(runner): show disk exhaustion before recovery errors (#22448)
Show the confirmed sandbox disk failure before a later lost-turn or restore error in saved run errors and both run detail views. Preserve the original diagnostics and leave scarce inodes available when preparing the existing runner relaunch reserve. Verified focused regressions, scoped typechecks, and full CI on the reviewed revision, including Runner checks and all eight end-to-end shards. Greptile is 5/5 with all review findings resolved. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
611dc68581
commit
b4cea5b5a4
10 files changed
+87
-14
No files matched your search
@@ -1,7 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { normalizeRunFailureCause, readRunFailureCause, RUN_FAILURE_CAUSE_MAX_LENGTH, withoutSqlStatementText } from "./run-failure-cause.js";
|
||||
import { normalizeRunFailureCause, readRunFailureCause, RUN_FAILURE_CAUSE_MAX_LENGTH, withoutSqlStatementText, runFailureMessage } from "./run-failure-cause.js";
|
||||
|
||||
describe("run failure cause contract", () => {
|
||||
it("leads with the confirmed full disk instead of the later restore failure", () => {
|
||||
expect(runFailureMessage({ errorCode: "sandbox_disk_full", error: "The previous turn is no longer active." }))
|
||||
.toMatch(/^The agent's computer ran out of disk space/);
|
||||
expect(runFailureMessage({ errorCode: "sandbox_disk_full", error: null })).toContain("Retry");
|
||||
expect(runFailureMessage({ errorCode: "process_lost", error: "Process lost" })).toBe("Process lost");
|
||||
expect(runFailureMessage({ errorCode: null, error: null })).toBeNull();
|
||||
});
|
||||
it("accepts bounded identifier codes", () => {
|
||||
for (const code of ["40001", "ECONNRESET", "provider_http_429", "TypeError", "signal_SIGKILL", "a".repeat(RUN_FAILURE_CAUSE_MAX_LENGTH)]) {
|
||||
expect(normalizeRunFailureCause(code)).toBe(code);
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
export const RUN_FAILURE_CAUSE_MAX_LENGTH = 80;
|
||||
export const RUN_FAILURE_CAUSE_PATTERN = /^[A-Za-z0-9_.:-]{1,80}$/;
|
||||
|
||||
export function runFailureMessage(run: { errorCode?: string | null; error?: string | null }): string | null {
|
||||
if (run.errorCode === "sandbox_disk_full") {
|
||||
return "The agent's computer ran out of disk space, so its runner stopped. "
|
||||
+ "Ask the agent to use less disk space, then select Retry. Saved task updates remain available.";
|
||||
}
|
||||
return run.error ?? null;
|
||||
}
|
||||
|
||||
/** The stored cause when it has the closed shape, else `null` (absent, legacy or malformed). */
|
||||
export function normalizeRunFailureCause(value: unknown): string | null {
|
||||
return typeof value === "string" && RUN_FAILURE_CAUSE_PATTERN.test(value) ? value : null;
|
||||
|
||||
Reference in new issue
Block a user