Files
PaperClipAI/packages/paperclip-runner/runner/crates/runner-core
Nicky LeachandPaperclip aa75ec9d56 Replay Claude native options on ACP reconnect (#18135)
## Thinking Path

> - Paperclip manages agents and their task execution.
> - Runner uses ACPX to connect to Claude sessions.
> - Claude receives native options when ACPX creates a session.
> - ACPX omits those options when it loads or resumes the same session.
> - A reconnect can lose allowed tools, instructions, and settings
sources.
> - This pull request replays the existing options through the existing
Claude metadata contract.
> - Resumed tasks keep the configuration admitted for their session.

## Linked Issues or Issue Description

**What happened?**
A Claude task can complete its first turn and then fail on a warm
follow-up. The provider refuses an internal completion tool because
`session/load` omits the `allowedTools` options sent with `session/new`.
The same omission exists on `session/resume`.

**Expected behavior**
Creation, load, and resume must supply the same caller-selected native
session options. The existing policy for native user settings must stay
unchanged.

**Steps to reproduce**
Create a persistent Claude ACP session with an explicit allowed-tool
list and appended instructions. Complete a turn, close its connection,
and reconnect to the saved session. Inspect the ACP request. Before this
change, the reconnect has no `_meta` field.

**Paperclip version or commit**
Reproduced on Runner source `e8b78cce5bb557b086bee9ca930eeaab1d09b244`.
The offline protocol regression also fails on the current base
`80a2b9284bf189e93ca4313085814548f48b8dc8`.

Related: #18089 added prepared harness storage. #11798 concerns the
separate legacy adapter and does not fix Runner reconnect metadata.

## Upstream status and backport scope

ACPX [0.21.1](https://github.com/openclaw/acpx/releases/tag/v0.21.1)
already replays session metadata on load and resume in its [released
client
implementation](https://github.com/openclaw/acpx/blob/v0.21.1/src/acp/client.ts).
This PR backports that behavior to the currently qualified 0.13.1
integration.

The released 0.21.1 runtime does not expose equivalents for all hooks
used by Runner's existing patch: verified executable spawning,
synchronous protocol admission guards, provider extension dispatch, and
response-delivery receipts. Upgrading requires a compatibility pass that
preserves these guarantees and removes local changes already covered
upstream. This backport does not add a new Paperclip-specific dependency
contract.

## What Changed

- Replay existing Claude native options on `session/load` and
`session/resume` through the same metadata builder used at creation.
Other providers keep their existing reconnect requests.
- Test both reconnect methods against the installed ACPX manager and a
local ACP wire fixture. Cover allowed tools, model, turn limit,
instructions, and both existing settings-source modes.
- Update exact source attestations and generated profile declarations
required by the shared ACPX patch. Keep historical fixtures unchanged.
- Document the reconnect contract. No new home mode, plugin policy, or
provider permission rule is added.

## Verification

- Confirmed the new load and resume tests fail before the patch because
metadata is absent.
- Applied the canonical patch to pristine package bytes and confirmed it
matches the tested runtime.
- Targeted installed-package model-selection and reconnect suite plus
changed Grok identity tests: 22 passed.
- Rechecked the four new reconnect cases against the cleanly applied
patch, with explicit expected values for all supplied options.
- Three targeted current-profile and revision-boundary assertions pass
locally. Updated the native Pi test digest; native compilation and
execution remain in CI.
- Maintained profile generators pass their consistency checks.
- GitHub CI is green, including typecheck, native Runner checks, package
contracts, packaged installation, build, and server/browser suites. One
unrelated server database-cleanup timeout passed on the bounded
failed-job rerun. No comprehensive local suite was run. Live
post-deployment acceptance remains pending.

## Risks

Claude reconnects now receive the same native settings sources and
options as creation. This corrects configuration loss without changing
caller policy. The shared dependency patch requires new source
identities for other attested profiles; their reconnect behavior is
unchanged. No database migration is required.

## Model Used

OpenAI Codex, GPT-6 family, with code and tool use. Exact deployment ID
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
#` / `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-10-29 01:45:18 -07:00
..