mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 11:59:26 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A person's Retry on a connected task (for example a GitHub pull request review) must start work. #21080 made a Retry whose chat replay is refused after the click continue from the recovered saved work > - After #21080 was deployed, accepted Retries on a busy GitHub review agent still did not start > - Those tasks had a saved chat request that arrived while the failed run was still running. Admission holds such a request as `message_predates_stop`, so it can never start alone > - #21080 refused to continue while any saved chat input existed, so this held input blocked the continuation. For a second group, the latest run was an admission that the recovery hold cancelled before dispatch, and the recovered saved work belongs to the earlier failed run > - This pull request lets the continuation adopt input that was held because it predates the stop, and lets the recovered run that held a cancelled admission count as the saved work > - The benefit is that an accepted Retry starts work on these tasks too ## Linked Issues or Issue Description Follow-up to #21080. No public issue exists. This is the bug description, in the fields of `.github/ISSUE_TEMPLATE/bug_report.yml`. **What happened?** After #21080 was deployed, `POST /api/issues/:id/retry` returned 202 for blocked tasks of a GitHub review agent (`paperclip_runner`), but no run started. Each Retry receipt changed to `failed` about 5 seconds later (on the 14:48 Retries, 5 seconds for one task and about 75 seconds for two others), with no run and no `issue.retry_continued_from_saved_work` activity. Every affected task had a saved chat request (a newer GitHub review request) with an `issue.execution_waiting` record of reason `message_predates_stop`. The request arrived while the failed run was running, so admission holds it permanently. The interruption projection kept pointing at that held request. In a second group of tasks, the latest run was cancelled before dispatch with `execution_reconciliation_required`, and the recovered saved work belonged to the earlier failed run that held it. Root cause: in `continueRefusedTaskChatRetry` (`server/src/services/task-retry.ts`), any saved chat input from `selectTaskRetryInput` stopped the continuation, so the receipt settled `failed`. The held input can never start by itself, so nothing ran. The recovered-work check also looked only at the latest run, so it missed the recovered run that held a cancelled admission. **Expected behavior** An accepted Retry starts work. Saved input that admission holds because it predates the stop joins the continuation, and the task continues from the recovered saved work. **Steps to reproduce** 1. Bind a task to a GitHub chat conversation. Let a native run fail with `native_continuation_requires_reconciliation`, and recover its saved work. 2. Save a chat request while that run is still running, so admission holds it with `message_predates_stop`. 3. Click Retry while the chat identity lock is busy, so the source check is deferred and then refused. 4. The route returns 202. The Retry receipt changes to `failed`, and no run starts. **Paperclip version or commit**a65644d1e1(the deployed #21080). Reproduced onef2b53b675. **Deployment mode** Hosted (cloud) instance with Daytona remote sandboxes and a GitHub chat connection. **Agent adapter(s) involved** `paperclip_runner` (native runs, and legacy admissions cancelled before dispatch). The fix is in core Retry code and is not adapter-specific. ## What Changed - `server/src/services/task-retry.ts` (`continueRefusedTaskChatRetry`): - Saved chat input whose source comment was written no later than the failed run's stop boundary (`userStopBoundaryAt`: the recorded user Stop request, otherwise `finishedAt`) no longer stops the continuation. This is the same boundary and timestamp that admission uses. Admission holds that input as `message_predates_stop`. The continuation coalesces its receipts into the Retry receipt (`coalescedIntoWakeupRequestId`), so the task stops waiting on it. The receipt ids are recorded in the activity details. - Saved input created after the stop, and unadmitted chat input, still settle the Retry as failed, as before. - When the latest run is an admission cancelled before dispatch (`execution_reconciliation_required`, never started), the recovered-work check also accepts the run named by that run's `executionWait.recoveryActionId`. - `doc/execution-semantics.md`: both rules. - Tests in `server/src/__tests__/chat-channels.integration.test.ts`: two new variants of the #21080 regression test. `person_with_input_before_stop` saves a chat request before the failed run stops. `person_after_held_admission` adds a legacy admission that the recovery hold cancelled. Both start one run that resumes the recovered workspace (`resume_preserved_workspace`). The held-admission fixture binds the task to the recovered workspace, as on the hosted tasks. Refusal edges `input_after_stop` and `input_inside_user_stop` settle the Retry failed with no run and leave the input deferred. ## Verification - Red before the fix: both new variants fail. The Retry receipt is `failed` (or stays held), and no run starts. - Green after the fix: both variants pass, and the held input receipt is coalesced into the Retry receipt. - `npx vitest run src/__tests__/chat-channels.integration.test.ts -t "[Rr]etry"` with `src/services/task-retry.test.ts` passes 369/369 on the final commit. - `npx tsc --noEmit -p server/tsconfig.json` passes. - Staging was read with GET requests only. ## Risks - Behavior change: input that arrived during a failed run no longer starts its own turn through the chat retry. It is adopted into the saved-work continuation, and the comment stays in the task thread. Before this change, that input could never start at all. - Input that arrived after the stop keeps its own admission path. - No migration. Receipts that already failed stay failed. The next click takes the new path. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (claude-opus-5-5), Anthropic, with tool use and code 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>