Files
PaperClipAI/server
DottaandClaude Opus 5.5 c72c468708 fix(github): a failed run's request waits for its automatic continuation (#23117)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Each GitHub request to a review bot gets a comment that must end in
a real reply or an honest notice, and stay correct
> - When a run fails with a cause the system continues automatically
(restart class, setup before provider work, recovery runs), a new run
follows within minutes
> - Both settle paths marked the request's comment "This turn stopped
before completing" and final as soon as the failed run ended, so the
continuation's answer never reached that thread
> - On staging, a Ponytail review run failed twice across a deploy; the
automatic retry succeeded three minutes later and updated the PR review
to 5/5, but the inline thread still says "stopped"
> - This pull request makes the request wait, for up to 30 minutes,
while the system's continuation is still expected
> - The benefit is that a recovered task's thread shows its real outcome
instead of a stale failure notice

## Linked Issues or Issue Description

Refs #22672, #23049

**Describe the bug**
A review run failed with `native_continuation_requires_reconciliation`
(twice, across a deploy). The system's automatic retry then succeeded
and updated the PR's main review comment. The inline thread for the
request had already been set to the final notice "This turn stopped
before completing" and was never updated.

**Steps to reproduce**
1. A request's run fails with an error the system continues
automatically.
2. The publication transport (`failRun`) or the terminal sweep settles
the request as "stopped" and final.
3. The automatic continuation succeeds and publishes, but the thread is
final and is not revisited.

**Expected behavior**
The thread waits while the continuation is expected, then shows the
continuation's reply or a link to the latest response; it says "stopped"
only if no continuation comes.

## What Changed

- `response-run-state.ts`: `responseRunColumns` adds
`continuesAutomatically` (the existing `continuesAutomaticallySql`),
read in the same statements as the rest of the run state.
- `response-execution.ts`: `awaitsAutomaticContinuation(run,
latestRun)`: the failed run continues automatically, is still the task's
latest run, and ended under 30 minutes ago
(`GITHUB_CONTINUATION_WAIT_MS`). While true the outcome is `waiting`,
and the result carries `awaitingContinuation`.
- `terminal-response-work.ts`: such a request is not parked, so the
sweep reads it again on later passes.
- `chat-github-response-comments.ts`: `failRun` defers with a conflict
while the continuation is awaited; once a newer run exists it is refused
as before and the sweep settles the request.

## Verification

- New test `waits for the automatic continuation of a failed GitHub
request run` (recent): fails on master (the thread says "stopped"),
passes here: `failRun` defers, the sweep keeps "Working on this…", then
the continuation and a newer response settle it with the link. Second
case (failure 31 minutes old) still settles "stopped".
- Updated `reconciles a GitHub working comment when execution stops
without a publication` to a failure older than the wait window, which is
what it tests.
- GitHub chat integration suites (response maintenance, finding threads,
workflow, retry and recovery, publications): 140 passed. Server
typecheck is clean.

## Risks

- A failed run's thread now shows "Working on this…" for up to 30
minutes while a continuation is expected, instead of "stopped" at once.
- Waiting requests are re-read on each sweep pass (bounded by the
30-minute window).

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.

## 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
- [ ] 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-27 15:09:48 +00:00
..