Files
PaperClipAI/server
Devin FoleyandPaperclip 837add0caa fix(recovery): deliver review-path repair instructions to agent prompts (#17353)
## Thinking Path

> - Paperclip keeps agent tasks moving through owned execution and
durable waiting paths.
> - A consumed review path gets one repair wake before board escalation.
> - That wake records an instruction to save a new monitor or another
real review path.
> - The canonical wake builder omitted that instruction from the agent
prompt.
> - This pull request delivers it through the existing
disposition-repair section.
> - The repair limit and execution authority stay unchanged.

## Linked Issues or Issue Description

**What happened?**

An agent opened a pull request and promised to watch CI and external
review. It ended without scheduling a monitor. Its bounded review repair
also ended without a maintained path, so the task became blocked for a
board decision. The saved repair context contained the instruction, but
the canonical wake payload and rendered prompt did not.

**Expected behavior**

The repair prompt tells the agent to save a one-shot monitor before
promising another check. Both fresh and resumed sessions receive that
instruction and the one-attempt limit.

**Steps to reproduce**

1. Create a review-path recovery with `decideIssueReviewPathRecovery`
for a task whose review path was consumed.
2. Pass its recorded context through `buildPaperclipWakePayload` and
wake serialization.
3. Render a fresh or resumed prompt. Before this fix, it has the wake
reason but no repair instruction.

**Paperclip version or commit**

Base: `9c442cf48e6`. Current head:
`f38d65891c8d9f2b38eb76a8578e870debc2b1e6`.

**Deployment mode**

Observed on managed sandbox execution with the legacy Claude ACP
adapter. The corrected canonical payload serves the shared adapter
prompt path.

Refs #15764 introduced the bounded exhausted-repair disposition. This
change preserves that limit. Open monitor-retry work such as #17171
addresses an already scheduled check; this defect occurs before a check
exists. Searches found no duplicate for this missing prompt field.

## What Changed

- Build the review-path repair disposition in its owning recovery
module, using the server instruction and fixed one-attempt bound.
- Project it into the existing canonical `dispositionRepair` field. No
new adapter field or execution protocol is added.
- Ignore arbitrary replacement instructions and attempt-limit values. A
pending repair keeps its instruction across a connection-pool retry that
changes the wake reason. Ordinary wakes without the typed repair marker
ignore raw instruction text. Existing legacy disposition repairs retain
their values.
- Add a regression across the real recovery decision, wake builder,
serializer and fresh/resumed prompt selectors. Update execution guidance
and the affected recovery maps.

## Verification

- Verified red before the source fix: two regression cases failed
because the instruction was absent; the sibling repair case passed. The
same cases pass after the fix.
- Passed 194 focused and safety tests across wake preparation, review
recovery, adapter prompt handling, and database-backed liveness
escalation. The connection-pool retry case also failed before its
correction and passes after it.
- Replayed the recorded incident wake through the fixed boundary. The
old canonical prompt lacked its saved instruction. The corrected
serialized prompt includes it with a 1/1 bound. This replay did not
execute a provider turn or change the source task. Private evidence
stays outside the repository.
- Passed `pnpm -r typecheck` after the pool-retry correction. Passed
`pnpm build` on final head `f38d65891c8d9f2b38eb76a8578e870debc2b1e6`.
Map checks and `git diff --check` pass.
- [Full
CI](https://github.com/paperclipai/paperclip/actions/runs/40005890857)
passed on that head: 54 checks passed and two optional checks were
skipped. This includes the full test shards, typecheck, build, and
browser suites. The local `pnpm test:run` attempt was stopped after the
CI test shards passed. No complete local full-suite pass is claimed.
- [Apex
review](https://github.com/paperclipai/paperclip/pull/17353#issuecomment-6372160694)
is 5/5 on the final head, with no open findings. The first review found
the pool-retry case. Its regression and correction are included. The
branch has no merge conflicts.
- Test setup first required the plugin SDK build, then an empty
credential-history database boundary. Those setup errors are not the
claimed red. The temporary recorded-wake probe was removed before final
validation.
- Hosted follow-up acceptance is not run. The source task remains
blocked and needs a retry after rollout. This PR does not claim that
prompt delivery itself schedules a monitor or that every model will
follow the instruction.

## Risks

- This fixes instruction delivery. The agent must still save a valid
monitor or another waiting path. The existing bounded escalation remains
if it does not.
- The wake stays a normal-model repair. It does not become status-only
recovery and can continue useful work. Existing ownership, approval,
budget, pause, and monitor admission gates remain in place.
- No schema, credential, telemetry, API, model, or retry-budget change.

## Model Used

OpenAI Codex, based on GPT-6, assisted with diagnosis, code editing,
shell execution and verification. The exact serving model ID and
context-window limit 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 (194 focused and safety
cases; full coverage passed in CI)
- [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-23 12:07:07 -07:00
..