Files
PaperClipAI/server
馨冉and馨冉 a02be1efc3 fix(continuation): degrade a stale interruptedRunId hint instead of failing the wake (#14807)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A wake builds its continuation envelope from a chain of
resume-source run ids: explicit user resume, retry chain, previous run,
then the interruptedRunId hint
> - interruptedRunId is a best-effort hint written when a run is
interrupted, and it is not cleared when an issue is reassigned to
another task
> - When the hint names another task's run (or a deleted row), the
envelope build threw continuation_source_context_missing, so the new
assignee's wake could never continue the work
> - This pull request degrades a stale interruptedRunId hint to "no
resume source" when it is the only source tier and does not resolve to
this task, while explicit user resume and retry chains stay fail-closed
> - The benefit is that cross-issue reassigns no longer brick an issue's
continuation wakes

## Linked Issues or Issue Description

Fixes #14723

## What Changed

- `server/src/services/execution-continuation.ts`: when
`interruptedRunId` is the only resume-source tier and the referenced run
is missing or belongs to another issue, continue without a resume source
instead of throwing `continuation_source_context_missing`
- The degraded envelope reports `trigger.sourceRunId: null` and no
longer re-echoes the stale `interruptedRunId` into the new envelope (so
the next wake does not inherit the poisoned hint)
- Explicit user resume (`explicitUserContinuation.previousRunId`),
`retryOfRunId`, and `previousRunId` tiers keep the existing fail-closed
throw (`continuation_user_authorization_missing` for explicit user
resume)
- `server/src/services/execution-continuation.test.ts`: the "rejects
handoff history from a different task" test is rewritten to the intended
degraded behavior, plus a deleted-row case and a fail-closed control
test for explicit user resume

## Verification

- `cd server && npx vitest run
src/services/execution-continuation.test.ts` — 35/35 pass (33 prior
tests plus 2 new; 1 existing test rewritten to the new intended
behavior)
- `npx tsc --noEmit` reports no errors in the touched files
- `git diff --check` is clean

Manual reasoning check: the degrade branch only fires when
`interruptedRunId` is the sole defined tier (`explicitUserSource`,
`retryOfRunId`, `previousRunId` all null) and the run does not resolve
to this task. Every other tier keeps the previous throw, covered by the
new control test.

## Risks

- Behavioral change: a wake that previously failed with
`continuation_source_context_missing` for a stale interrupted-only hint
now continues without resume history. This is the intended fix per the
issue; the fail-closed invariant is preserved for all user-driven and
retry source tiers
- The `interruptedRunId` no longer propagates into the envelope when
stale, so downstream consumers no longer see the stale id (they would
previously only see it when the envelope build succeeded, which it never
did for this case)

## Model Used

Codex (OpenAI Codex CLI, GPT-5 based coding agent, repository-aware tool
use, ~1M context window, extended reasoning), assisted by three
read-only explorer sub-agents for issue triage and duplicate checking.

## 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: 馨冉 <xinxincui239@gmail.com>
2026-10-26 20:48:14 -07:00
..