mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 18:35:33 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - When a managed run fails, Paperclip classifies the failure to decide
whether to retry it
> - A run whose setup exceeded the runner's durable limits failed with
`durable_prp_canonical_json_too_large`, which was classified as an
interrupted session
> - Paperclip retried it three times and then continued the task in a
fresh session that failed the same way: one agent produced 20 failed
runs in a few minutes, and the task showed a raw internal code
> - This pull request classifies oversized run setups as a permanent
failure with a plain-language action
> - The benefit is no pointless retries, and the user learns what to
change
## Linked Issues or Issue Description
**What happened?**
An agent's run setup was larger than the runner's durable control plane
accepts. Each attempt failed in seconds with
`durable_prp_canonical_json_too_large`. Paperclip scheduled retries and
fresh-session continuations that could never succeed, and the task
showed the raw code.
**Expected behavior**
A failure that the same input will always repeat is not retried. The
user sees what to change.
**Steps to reproduce**
1. Classify `new Error("durable_prp_canonical_json_too_large")` with
`nativeSessionFailureSourceCode`.
2. The disposition is `retryable_failure` with
`native_session_interrupted`.
## What Changed
- New `native-run-payload-too-large.ts`: the
`native_run_payload_too_large` code, its user-facing action, and the
matcher for `durable_prp_canonical_json_too_large` and
`command_payload_too_large`.
- `native-session-executor.ts`: classify those errors as
`native_run_payload_too_large`, treat it as permanent, and show the
action.
- `heartbeat/retries.ts`: do not schedule a retry for it.
- `native-sandbox-disk-full.ts`: a full disk does not relabel this code.
- Tests for classification, disposition and retry scheduling.
## Verification
- `npx vitest run
src/services/native-runtime/native-run-payload-too-large.test.ts
src/__tests__/heartbeat-retry-scheduling.test.ts`: 75 passed.
- Red/green: without the change, 4 of the new assertions fail.
- The underlying size mismatch is fixed separately in
paperclipai/paperclip#22705. This change makes any future deterministic
size failure stop at once instead of looping.
## Risks
- Low. Only these two deterministic size errors change classification.
All other failures keep their existing retry behavior.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code, with tool use.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.5 KiB
TypeScript
75 lines
3.5 KiB
TypeScript
import { JsonRpcCallError, PLUGIN_RPC_ERROR_CODES } from "@paperclipai/plugin-sdk";
|
|
import { isSandboxDiskFullFailure } from "../../vendor/paperclip-runner/index.js";
|
|
import { isSandboxDiskFullText } from "./remote-runner-disk-reserve.js";
|
|
import { NATIVE_RUN_PAYLOAD_TOO_LARGE } from "./native-run-payload-too-large.js";
|
|
|
|
export const NATIVE_SANDBOX_DISK_FULL = "sandbox_disk_full" as const;
|
|
|
|
export const NATIVE_SANDBOX_DISK_FULL_ACTION =
|
|
"The agent filled the disk of its computer, so its runner stopped. Paperclip does not repeat this automatically: "
|
|
+ "a new computer has the same disk size, and the same work would fill it again. Ask the agent to use less disk space, "
|
|
+ "for example by deleting build output, caches or dependencies it no longer needs, then press Retry.";
|
|
|
|
const CODES_THAT_KEEP_THEIR_MEANING: ReadonlySet<string> = new Set([
|
|
NATIVE_RUN_PAYLOAD_TOO_LARGE,
|
|
"native_permission_declined",
|
|
"native_provider_approval_required",
|
|
"native_provider_usage_limit",
|
|
"native_provider_model_rejected",
|
|
"native_provider_runtime_missing",
|
|
"native_provider_state_incompatible",
|
|
"native_provider_side_effect_pending",
|
|
"native_provider_startup_rejected",
|
|
"native_event_replay_conflict",
|
|
"native_session_cleanup_quarantined",
|
|
"native_governed_wait_settlement_pending",
|
|
"native_predecessor_retirement_unproven",
|
|
"native_adopted_runner_authentication_timeout",
|
|
"native_controller_journal_behind_runner",
|
|
"native_current_wake_comments_unread",
|
|
"native_current_wake_comments_changed_after_read",
|
|
"runner_task_admission_rejected",
|
|
"runner_ingress_access_rejected",
|
|
"runner_remote_provider_artifact_incompatible",
|
|
"planning_mode_unsupported",
|
|
]);
|
|
|
|
const NAMED_DISK_FULL_FAILURE = /(?:^|: )sandbox_disk_full: /;
|
|
|
|
export function isNativeSandboxDiskFullReport(text: string): boolean {
|
|
return isSandboxDiskFullText(text) || NAMED_DISK_FULL_FAILURE.test(text);
|
|
}
|
|
|
|
function diskFullCause(error: unknown, depth = 0): boolean {
|
|
if (!error || typeof error !== "object" || depth > 5) return false;
|
|
if (isSandboxDiskFullFailure(error)) return true;
|
|
const value = error as { cause?: unknown; errors?: unknown; message?: unknown };
|
|
if (typeof value.message === "string" && NAMED_DISK_FULL_FAILURE.test(value.message)) return true;
|
|
return diskFullCause(value.cause, depth + 1)
|
|
|| (Array.isArray(value.errors) && value.errors.slice(0, 3).some(item => diskFullCause(item, depth + 1)));
|
|
}
|
|
|
|
function sandboxProviderDiskFullCause(error: unknown, depth = 0): boolean {
|
|
if (!error || typeof error !== "object" || depth > 5) return false;
|
|
if (isSandboxDiskFullFailure(error)) return true;
|
|
if (error instanceof JsonRpcCallError && error.code === PLUGIN_RPC_ERROR_CODES.WORKER_ERROR
|
|
&& isNativeSandboxDiskFullReport(error.message)) return true;
|
|
const value = error as { cause?: unknown; errors?: unknown; message?: unknown };
|
|
if (typeof value.message === "string" && NAMED_DISK_FULL_FAILURE.test(value.message)) return true;
|
|
return sandboxProviderDiskFullCause(value.cause, depth + 1)
|
|
|| (Array.isArray(value.errors) && value.errors.slice(0, 3).some(item => sandboxProviderDiskFullCause(item, depth + 1)));
|
|
}
|
|
|
|
export function isSandboxProviderDiskFullError(error: unknown): boolean {
|
|
return sandboxProviderDiskFullCause(error);
|
|
}
|
|
|
|
export function nativeSandboxDiskFullSourceCode<T extends string>(
|
|
code: T,
|
|
error: unknown,
|
|
runnerSandboxDiskFull: boolean,
|
|
): T | typeof NATIVE_SANDBOX_DISK_FULL {
|
|
if (CODES_THAT_KEEP_THEIR_MEANING.has(code)) return code;
|
|
return runnerSandboxDiskFull || diskFullCause(error) ? NATIVE_SANDBOX_DISK_FULL : code;
|
|
}
|