## Thinking Path > The ACPX engine reports a mid-stream transport stall and a hard provider capacity cap under one code, `acpx_turn_failed`, but they want opposite retry semantics. Because the engine never persists `errorFamily`, the heartbeat bounded-retry ladder never arms for transport stalls (issue #11257). This classifies the two at the adapter, tagging stalls `transient_upstream` while leaving the capacity-cap subclass on its `provider_quota` path. ## Linked Issues or Issue Description Fixes #11257. Searched the open PR list — no existing PR adds ACPX transport-stall errorFamily classification. ## What Changed Rebased onto the new terminal-failure classification (`terminalFailureClassification` + per-adapter `classifyTerminalSessionFailure`). The adapter classifiers (`classifyClaudeTerminalSessionFailure`, `classifyCodexTerminalSessionFailure`) only cover `access` and provider-quota `limit` failures, so a mid-stream stall is still left with no `errorFamily` on `master`. - **`classifyAcpxTurnFailureErrorFamily(error, terminalSessionFailure?)`** (pure, exported): returns `"transient_upstream"` only for the transport-stall signature. Capacity/quota wording vetoes first, and an `access` / `limit` terminal-session category is never relabelled. - **Engine wiring**: used as a fallback **after** `classifyToolDefinitionFailure` and the adapter classifier — `terminalFailureClassification ?? fallback`. Adapter labels always win; `errorCode` stays `acpx_turn_failed`. The family flows through the existing `classifiedFailure` path into the top-level result and `resultJson`. No server change. ## Verification - `pnpm exec vitest run packages/adapter-utils/src/acpx-engine/execute.test.ts` — 232 passed, including: stall/cap/unrelated unit cases, two remote-harness runs (stall → `transient_upstream`, session cap → none), and three `classifyTerminalSessionFailure` cases (unclaimed stall → `transient_upstream`; adapter `provider_quota` wins over the fallback; unclaimed `limit` failure with stall wording stays unlabelled). - `vitest run packages/adapters/claude-local packages/adapters/codex-local` — green. - `tsc --noEmit` — `packages/adapter-utils` and `server` 0 errors. ## Risks - Text-based classification: an unmatched reword is a safe false-negative (preserves today's no-retry). A stall surfacing as a thrown error rather than a failed terminal is a follow-up. ## Model Used - Claude Opus 4.8 (Anthropic), 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` URLs) - [x] My branch name describes the change and contains no internal ticket id - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s cc @cryppadotta @devinfoley — rebased onto the new `terminalFailureClassification` scheme; CI and Greptile are green, ready for review.
@paperclipai/adapter-utils
Shared utilities for Paperclip adapters: process spawning, environment injection, sandbox/SSH transport, workspace sync, and the round-trip helpers that move code between the local execution-workspace cwd and wherever the agent actually runs.
For the adapter-author guide see
docs/adapters/creating-an-adapter.md
and the in-repo notes at packages/adapters/AUTHORING.md.
Sandbox bridge deadlines
Command-managed bridge control operations (queue reads, input delivery, setup, and cleanup) have a host-enforced deadline of at most 30 seconds per shell command. A shorter configured timeout still applies. These operations cannot inherit the agent run's hours-long lifetime or wait forever on a provider that ignores its timeout. Long-lived agent session commands keep their own limits.
A control timeout reports a transport failure. It does not prove that the remote command stopped and does not replay an uncertain write. The process session closes failed input delivery and uses its existing shutdown path; normal execution settlement must still verify termination.
Native archive transfer deadlines
Native syncIn and syncOut calls accept an optional minimumTimeoutMs budget. The
server validates this budget and extends the worker RPC deadline. Providers can
honor this field for file transfers without changing their configuration. Daytona
uses the larger of this minimum and its configured timeout. Other providers keep
their existing behavior. The minimum is limited to 30 minutes and does not change
sandbox lifetimes, stored settings or the timeout for other commands.
The remote-workspace archive path uses the verified capture size for downloads and the local archive size for uploads. Large archives get one second per MiB plus 60 seconds, capped at 30 minutes. Small archives keep the existing provider timeout when that calculation is no greater than five minutes. Archive size, checksum, confinement and host space checks still apply.
An exact retained-sandbox resume keeps its recorded provider timeout and RPC overhead. It uses the normal one-minute fallback only when no timeout was recorded. A five-minute cold restore must not be cut off by that fallback. Resume still targets the recorded allocation and does not acquire a replacement.
No-remote-git contract
The local execution-workspace cwd is the only persistence boundary across runs. No adapter may depend on a git remote for cross-run state.
Adapters that run the agent on a different host should use the SSH round-trip
helpers in src/ssh.ts:
prepareWorkspaceForSshExecution({ spec, localDir, remoteDir })— bundles the local cwd (tracked files, dirty edits, untracked additions, and the git history needed to reconstruct it) toremoteDirbefore the run starts. Runs with nogit remoteconfigured.restoreWorkspaceFromSshExecution({ spec, localDir, remoteDir, ... })— syncs the remote cwd back intolocalDirafter the run, including any new commits the agent created. Also runs with nogit remoteconfigured.
prepareRemoteManagedRuntime in
src/remote-managed-runtime.ts wraps both
calls for adapters that want a per-run remote workspace and an automatic
restoreWorkspace() finally hook.
The invariant is pinned by the no-remote-git contract case in
src/ssh-fixture.test.ts, which asserts that a
remote-only commit propagates to the local worktree through the
prepare → restore round-trip with no git remote configured at any point. Do
not regress that test.