Files
PaperClipAI/packages
DottaandClaude Opus 5.5 4ea6fa61d5 fix(runner): re-prepare OpenCode launch inputs for a replaced provider session (#23050)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Native OpenCode agents run in remote sandboxes. The controller gives
each Runner launch the provider-pack paths of Node, the OpenCode proxy
and the OpenCode executable
> - When exact resume of a provider session fails, Paperclip archives
the old session and opens a replacement session on the same backend
> - The archive drops the restored provider artifacts and their launch
paths. The replacement transport reads its launch inputs when it is
built, before its Runner is staged
> - A session restored from saved artifacts never selects a pack root,
so the replacement had no OpenCode executable. The run failed as
`runner_remote_provider_artifact_incompatible` and the task stayed
blocked. Other replacements launched from the pack root while the saved
receipt named the artifact root, and the next continuation's Runner
rejected that launch
> - This pull request stages the launch inputs again before the
replacement opens, reports a missing launch input as a retryable
controller gap, and continues tasks that older releases blocked this way
> - The benefit is that a GitHub review (or any OpenCode task) that hits
a resume failure continues by itself instead of needing a Retry

## Linked Issues or Issue Description

Refs #22981 (it scoped staged provider assets per provider; it did not
cause or fix this failure)

**What happened?**
An OpenCode review run on a hosted instance failed with
`runner_remote_provider_artifact_incompatible: OpenCode executable is
missing from the provider pack`. The task stayed blocked with no later
run. The run log showed the adopted Runner first refusing `run.attach`
with "OpenCode run.prepare launch does not match the runner-owned
qualified profile". The previous run of the same session had replaced
its provider session after a failed exact resume.

**Expected behavior**
A replaced provider session launches with the same verified OpenCode
inputs as any other launch, and the task continues without a person
pressing Retry.

**Steps to reproduce**
1. Run an OpenCode agent in a remote sandbox with durable harness
storage, so the session restores its provider artifacts.
2. Make exact resume fail, so the backend opens a replacement session.
3. Build the replacement transport. It has no `opencodeCommand`, and the
transport throws "OpenCode executable is missing from the provider
pack".

**Paperclip version or commit**
master at 85ad16b47e

## What Changed

- `native-session-executor.ts`: `openReplacementSession` stages the
remote Runner launch inputs again (`prepareNativeRemoteRunner`) after
the continuity archive and before the replacement session opens. The
replacement now launches from the same verified artifact root that its
saved receipt names.
- `runnerd-codex-transport.ts`: a controller launch that omits
provider-pack inputs (OpenCode executable, proxy, provider Node, ACPX
sidecar, or verified digests) now fails as
`runner_remote_provider_launch_unprepared`. The pack itself was never
judged, so this is not a pack incompatibility.
- `native-session-executor.ts`:
`runner_remote_provider_launch_unprepared` is classified by name and is
not permanent. The run retries with a fresh backend (bounded to three
attempts, 30 s apart), which prepares the inputs again.
- `continuation-cause.ts`, `native-interruption-continuation.ts`: an
active hold left by an older release with cause
`runner_remote_provider_artifact_incompatible` and the exact legacy
"OpenCode executable is missing from the provider pack" error now goes
through the native interruption lane. That lane starts one fresh
continuation, with the existing pacing. Genuine pack incompatibilities
stay held.

Previous-release story (upgrade-safe run state): no persisted shape
changes. A session saved by the previous release with a replacement
launched from the pack root is not resumed in place. The fresh
continuation archives it and launches a new provider session from
verified inputs.

## Verification

- Red/green: `native-session-executor.test.ts` variant
`opencode-continuation-prior-receipt-replacement`. Without the fix, the
replacement transport options have no `opencodeCommand` or
`providerNodeCommand` (the staging failure). With the fix, they name the
artifact root.
- `fresh-continuation-fallback.test.ts`: a task held by the legacy
failure gets exactly one fresh successor. A task held by a real manifest
digest mismatch stays blocked.
- `native-session-executor.test.ts`: the new code is retried in the same
run and exhausts at the third attempt.
- Commands:
- `cd server && npx vitest run
src/services/native-runtime/native-session-executor.test.ts
src/services/fresh-continuation-fallback.test.ts`
- `cd packages/paperclip-runner && npx vitest run
src/live/runnerd-codex-transport.test.ts`
  - `npx tsc --noEmit` in `server` and `packages/paperclip-runner`
- Not verified locally: a live remote sandbox replacement. Staging
verification follows the deploy.

## Risks

- A replacement session now stages the remote Runner and provider pack
again. This adds the normal preparation time only on the replacement
path, which already starts a new provider session.
- If the controller keeps omitting launch inputs for another reason, the
run retries at most three times and then blocks as
`native_session_retry_exhausted`. No retry storm is possible.
- The legacy match is exact on the error text, so other
`runner_remote_provider_artifact_incompatible` failures keep their
current behavior.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell,
code search, test execution) in Claude Code.

## 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>
2026-11-26 14:12:16 +00:00
..