Files
PaperClipAI/packages/adapter-utils
Nicky LeachandPaperclip c3ffa3f0dd test(adapter-utils): fix feedback request index in bridge round trip (#16507)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Sandbox agents use the callback bridge to call the Paperclip API.
> - The bridge round-trip test checks request delivery and credential
removal.
> - #12785 added an accepted API-key request before the feedback
request.
> - The feedback assertions still read request 2, which is now the
GitHub credentials request.
> - This PR checks request 3 and verifies that all four accepted
requests reached the host.
> - This restores the shared test gate while retaining the Unicode
payload and token checks.

## Linked Issues or Issue Description

Related PR: #12785 introduced the stale feedback index. The reported
failure appears on #16486 and master. Searches for `workspaces-b`,
`sandbox-callback-bridge`, `surrogate`, and `EncoderFallbackException`
found no duplicate fix.

**What happened?**

The `General tests (workspaces-b)` job fails on PRs and master. The
hosted PR job and AWS master job both report
`System.Text.EncoderFallbackException` for an unpaired `\uD83D`. The
runner exits during the test step and does not upload that step's log.

The unchanged master test reproduces a deterministic assertion failure
at the feedback request. It compares `/runtime-tools/github/credentials`
with `/api/companies/company-1/agent-commentary` and prints a diff
containing 5,000 crying emoji. The assertion output is the likely
trigger for the runner's Unicode logging crash.

- [Reported PR
job](https://github.com/paperclipai/paperclip/actions/runs/38818474563/job/116719880033)
- [Master job with the same runner
exception](https://github.com/paperclipai/paperclip/actions/runs/38821128038/job/116717690951)

**Expected behavior**

The test checks the actual feedback request, verifies its full payload,
and confirms that its authorization header is removed. Both shared CI
lanes complete normally.

**Steps to reproduce**

1. Check out master at `c4a16cbe981f96e2756c7014103c88da67e5514f`.
2. Install dependencies with pnpm 9.15.4.
3. Run `node_modules/.bin/vitest run
packages/adapter-utils/src/sandbox-callback-bridge.test.ts -t
'round-trips localhost bridge requests'`.
4. Observe the feedback assertion reading the preceding GitHub
credentials request.

**Paperclip version or commit**

Master at `c4a16cbe981f96e2756c7014103c88da67e5514f`.

**Deployment mode**

Built from source. GitHub-hosted PR CI and AWS post-merge CI.

## What Changed

- Assert that four accepted requests reached the host.
- Check feedback delivery and authorization stripping on request 3.
- Retain the large Unicode payload and all existing authentication
checks.

## Verification

- Unchanged master: the focused round-trip test fails at the stale
feedback index.
- Fixed branch: all 68 tests in `sandbox-callback-bridge.test.ts` pass
with real localhost gateways.
- `pnpm --filter @paperclipai/adapter-utils typecheck` passes.
- `git diff --check` passes.
- Exact CI group: `node scripts/run-vitest-stable.mjs --mode general
--group general-workspaces-b` passes (4,800 tests passed, 28 skipped
across 17 projects).
- `pnpm --filter @paperclipai/adapter-utils build` passes.
- Greptile reviewed current head
`3de15d3374354809ea84ca4df5f93c2473715f02`: 5/5, success, no comments or
actionable findings.
- All GitHub checks pass on current head
`3de15d3374354809ea84ca4df5f93c2473715f02`: 55 successful checks and 2
intentional skips, including `workspaces-b`, build, typecheck, Runner
verification, and e2e.
- Full local `pnpm test:run` was started and stopped after the CI test
lanes passed; it did not complete locally. No worktree-owned test
processes remained afterward.
- Full local typecheck and build were attempted. Both stop at the Runner
Rust commands because `cargo` is absent from the shell PATH. The changed
package typecheck passes. The complete repository typecheck and build
pass in CI.
- The first sandboxed local reproduction could not bind localhost
(`EPERM`). It was repeated with listener permission and reached the
deterministic assertion failure described above.

## Risks

Low risk. This changes three test lines. Runtime behavior, credentials,
workflow settings, and payload coverage stay the same. The GitHub runner
Unicode logging defect remains upstream; this fix removes the incorrect
assertion that triggers it in this test.

## Model Used

OpenAI GPT-6 in Codex, with reasoning, repository inspection, and
command execution. The exact runtime model identifier and context window
size are not exposed in this session.

## 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
#` 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-10-15 16:32:20 -07:00
..

@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.

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) to remoteDir before the run starts. Runs with no git remote configured.
  • restoreWorkspaceFromSshExecution({ spec, localDir, remoteDir, ... }) — syncs the remote cwd back into localDir after the run, including any new commits the agent created. Also runs with no git remote configured.

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.