paperclip/packages
Nicky Leach d1ba17eeca
fix(adapter-utils): fail fast when the sandbox control channel is lost mid-turn (#13158)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Adapter utilities run agent turns and report their results to the
control plane
> - A lost sandbox control channel can leave an agent turn without a
result
> - The host then waits for the full adapter timeout instead of
reporting the loss
> - This pull request adds a push loss signal and a bounded host wait
> - The benefit is a prompt failure terminal when the agent stops
answering

## Linked Issues or Issue Description

**What happened?**

A sandbox control channel loss during an Agent Client Protocol turn left
the host waiting for the four-hour adapter execution timeout.

**Expected behavior**

The host should detect the terminal channel loss, stop the turn, and
report a safe failure without waiting for the agent.

**Steps to reproduce**

1. Start an Agent Client Protocol turn through a sandbox adapter.
2. Close the duplex control channel while the turn remains active.
3. Observe the host response before the adapter timeout expires.

**Paperclip version or commit**

Test the pull request commit set at
`10b6bbc5525a79fd575298607dd5a25ae448fc8a`.

**Deployment mode**

The change applies to sandbox-backed adapter execution.

## What Changed

- Add `onLoss(listener)` to the duplex bridge handle.
- Register the loss listener at turn start and read losses latched
before turn start.
- Cancel the turn on loss and arm a 30-second host deadline.
- Close the stream locally when the deadline wins and create a host
terminal.
- Derive the public error from the closed `DuplexLossReason` enum.
- Add tests for loss order, cancellation, timeout, and safe error
output.

## Verification

- Run `pnpm --filter @paperclipai/adapter-utils exec tsc --noEmit`.
- Run `pnpm --filter @paperclipai/adapter-utils exec vitest run
src/acpx-engine/execute.test.ts -t "run-disposition seam"`.
- Confirm that the full pull request workflow passes.

## Risks

The new deadline changes a lost-channel path from a long wait to a
host-built failure after 30 seconds. Orderly completion keeps its
existing behavior. The deadline race against a pending `turn.result` has
no direct test.

## Model Used

OpenAI Codex, GPT-5, with tool use and code execution. The runtime does
not expose a more specific deployment version or context-window size.

## 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
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-09-10 15:37:05 -07:00
..
adapter-utils fix(adapter-utils): fail fast when the sandbox control channel is lost mid-turn (#13158) 2026-09-10 15:37:05 -07:00
adapters feat: bind an agent to a Codex login whose account differs from the company default (#13067) 2026-09-10 07:15:01 -07:00
db feat: bind an agent to a Codex login whose account differs from the company default (#13067) 2026-09-10 07:15:01 -07:00
google-sheets-mcp-server chore(deps-dev): bump vitest from 4.1.10 to 4.1.11 (#12262) 2026-09-03 15:16:02 -07:00
kv-demo-mcp-server chore(deps-dev): bump vitest from 4.1.10 to 4.1.11 (#12262) 2026-09-03 15:16:02 -07:00
mcp-server chore(deps-dev): bump vitest from 4.1.10 to 4.1.11 (#12262) 2026-09-03 15:16:02 -07:00
paperclip-eval-kernel feat(runner): add offline evaluation tooling (#12653) 2026-09-01 05:19:47 -05:00
paperclip-runner fix(paperclip-runner): bump claude-agent-acp pin to 0.73.0 (#13162) 2026-09-10 11:35:33 -07:00
plugins fix(runner): persist warm Daytona workspaces (#12901) 2026-09-05 13:00:57 -05:00
shared feat: add experimental native chat connectors (#13038) 2026-09-10 10:06:45 -05:00
skills-catalog feat(apps): add secure remote MCP and PostHog setup (#12339) 2026-08-29 12:08:32 -05:00
tailscale-https-broker chore(deps-dev): bump vitest from 4.1.10 to 4.1.11 (#12262) 2026-09-03 15:16:02 -07:00
teams-catalog fix(build): enforce Node 24 across Paperclip (#11792) 2026-08-21 10:17:52 -07:00