mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
fix(runs): stop retrying a run whose setup is too large to start (#22707)
## 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>
This commit is contained in:
1 parent
bda1bf7b52
commit
1363b557b9
6 files changed
+68
-1
No files matched your search
@@ -8,6 +8,7 @@ import { nativeLeaseHolder, notifyNativeTokenLeaseClaimed } from "./native-token
|
||||
import { captureRemoteNativeProviderArtifacts, shareNativeProviderArtifactCapture } from "./native-provider-artifact-capture.js";
|
||||
import { NativeSessionDiagnostics, nativeSessionDiagnostics, type NativeDiagnosticLease } from "./native-session-diagnostics.js";
|
||||
import { NATIVE_SANDBOX_DISK_FULL, NATIVE_SANDBOX_DISK_FULL_ACTION, nativeSandboxDiskFullSourceCode } from "./native-sandbox-disk-full.js";
|
||||
import { isNativeRunPayloadTooLarge, NATIVE_RUN_PAYLOAD_TOO_LARGE, NATIVE_RUN_PAYLOAD_TOO_LARGE_ACTION } from "./native-run-payload-too-large.js";
|
||||
import { runFailureMessage } from "@paperclipai/shared";
|
||||
import { recordAgentProviderRateLimits } from "../agent-provider-rate-limits.js";
|
||||
import { nativePostResultFailureCategory, type NativePostResultFailureCategory } from "./native-post-result-failure.js";
|
||||
@@ -9087,7 +9088,8 @@ export function nativeSessionFailureDisposition(
|
||||
sourceFailureCode === NATIVE_PROVIDER_SESSION_CLOSED ||
|
||||
sourceFailureCode === NATIVE_PROVIDER_STARTUP_REJECTED ||
|
||||
sourceFailureCode === NATIVE_CONTROLLER_JOURNAL_BEHIND_RUNNER ||
|
||||
sourceFailureCode === NATIVE_SANDBOX_DISK_FULL;
|
||||
sourceFailureCode === NATIVE_SANDBOX_DISK_FULL ||
|
||||
sourceFailureCode === NATIVE_RUN_PAYLOAD_TOO_LARGE;
|
||||
const permissionDeclined = sourceFailureCode === "native_permission_declined";
|
||||
const exhausted = permanentFailure || permissionDeclined || attempt >= 3;
|
||||
return {
|
||||
@@ -9289,6 +9291,7 @@ function classifyNativeSessionFailure(
|
||||
error: unknown,
|
||||
):
|
||||
| "native_permission_declined"
|
||||
| typeof NATIVE_RUN_PAYLOAD_TOO_LARGE
|
||||
| "native_provider_terminal_failed"
|
||||
| "native_governed_wait_settlement_pending"
|
||||
| typeof NATIVE_PROVIDER_STATE_INCOMPATIBLE
|
||||
@@ -9371,6 +9374,7 @@ function classifyNativeSessionFailure(
|
||||
if (runnerClosedTurnStartSession(error)) return NATIVE_PROVIDER_SESSION_CLOSED;
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
if (/"code":"controller_sequence_mismatch"/.test(message)) return NATIVE_CONTROLLER_JOURNAL_BEHIND_RUNNER;
|
||||
if (isNativeRunPayloadTooLarge(error)) return NATIVE_RUN_PAYLOAD_TOO_LARGE;
|
||||
if (/^(?:runner_ingress_unavailable: runnerd exited unexpectedly with code 1: )?runner_task_admission_rejected: (session_state_unavailable|account_binding_mismatch)$/.test(message)) {
|
||||
return "runner_task_admission_rejected";
|
||||
}
|
||||
@@ -13610,6 +13614,8 @@ async function executePaperclipNativeSessionAttempt(
|
||||
? "The computer provider rejected access. Restore the environment's credentials or permissions before retrying. Automatic retries are stopped."
|
||||
: sourceFailureCode === NATIVE_SANDBOX_DISK_FULL
|
||||
? NATIVE_SANDBOX_DISK_FULL_ACTION
|
||||
: sourceFailureCode === NATIVE_RUN_PAYLOAD_TOO_LARGE
|
||||
? NATIVE_RUN_PAYLOAD_TOO_LARGE_ACTION
|
||||
: sourceFailureCode === "native_provider_terminal_failed"
|
||||
? "The provider session is permanently unusable. Verify stopped execution, completed actions, and task context before starting a linked continuation."
|
||||
: sourceFailureCode === "native_governed_wait_settlement_pending"
|
||||
@@ -13902,6 +13908,8 @@ async function executePaperclipNativeSessionAttempt(
|
||||
? "The computer provider rejected access. Restore the environment's credentials or permissions before retrying. Automatic retries are stopped."
|
||||
: sourceFailureCode === NATIVE_SANDBOX_DISK_FULL
|
||||
? NATIVE_SANDBOX_DISK_FULL_ACTION
|
||||
: sourceFailureCode === NATIVE_RUN_PAYLOAD_TOO_LARGE
|
||||
? NATIVE_RUN_PAYLOAD_TOO_LARGE_ACTION
|
||||
: sourceFailureCode === "native_provider_terminal_failed"
|
||||
? "Verify that the failed provider stopped and reconcile its action outcomes. A linked continuation can proceed only after these checks succeed."
|
||||
: sourceFailureCode === "native_provider_model_rejected" && !recoveryEvidence.providerSessionEstablished
|
||||
|
||||
Reference in new issue
Block a user