fix(heartbeat): stop carrying the in_review wait into later summaries (#15544)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - After each run, Paperclip refreshes the issue's continuation
summary. In review, its Next Action says to wait for reviewer feedback
> - Later refreshes copy that line into in-progress issues, so the
dispatcher cancels the queued continuation
> - This pull request stops that copy

## Linked Issues or Issue Description

Refs #14424. Agents on an issue that came back from review get their
queued continuation runs cancelled with
`issue_continuation_waiting_on_review`. Builds on the repro and check
from @mnazirp-finity. Related: #11614.

## What Changed

- `inferNextAction` no longer carries the Next Action it writes for an
in_review issue into another status.
- Tests: the issue's repro, a kept waiting Next Action, and a Postgres
test for the queued continuation.

## Verification

- `pnpm exec vitest run issue-continuation-summary.test.ts
run-dispatch/adapters/postgres.test.ts`

## Risks

Low. Stored summaries with the wait line change after the next run.

## Model Used

The AI assistance note is at the end.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [x] ROADMAP.md lists no planned core work that overlaps this PR
- [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
- [ ] 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

Assisted by Claude/Codex.

Co-authored-by: mnazirp-finity
<317764857+mnazirp-finity@users.noreply.github.com>

Co-authored-by: mnazirp-finity <317764857+mnazirp-finity@users.noreply.github.com>
This commit is contained in:
Arthurandmnazirp-finity authored and GitHub committed 2026-12-04 21:23:21 -08:00
1 parent 6520046f35
commit 2eea950c2e
3 files changed
+87 -2

No files matched your search

@@ -41,6 +41,7 @@ import { projectTaskInterruption } from "../../../services/task-interruption-pre
import { reserveRunBudget } from "../../../services/budget-reservations.js";
import { budgetService, flushBudgetEvaluationWork, recheckAdmittedRunBudgetReadOnly } from "../../../services/budgets.js";
import { costService } from "../../../services/costs.js";
import { refreshIssueContinuationSummary } from "../../../services/issue-continuation-summary.js";
// Proves the DB-to-facts mapping this adapter owns for each state the two
// run-dispatch gates decide on. `application/use-cases.test.ts` and
@@ -1440,6 +1441,40 @@ describeEmbeddedPostgres("run-dispatch postgres adapter", () => {
errorCode: "issue_continuation_waiting_on_review",
});
});
it("keeps a continuation queued after the summary was refreshed for an issue back in progress", async () => {
const { companyId, agentId } = await seedCompanyAndAgent();
const issueId = randomUUID();
await seedIssue({ companyId, issueId, status: "in_review", assigneeAgentId: agentId });
const agent = { id: agentId, name: "Agent", adapterType: "claude_local" };
const finishRun = async () => {
const id = await seedRun({ companyId, agentId, contextSnapshot: { issueId } });
await db.update(heartbeatRuns).set({ status: "succeeded", finishedAt: new Date() }).where(eq(heartbeatRuns.id, id));
return { id, status: "succeeded", error: null };
};
await refreshIssueContinuationSummary({ db, issueId, agent, run: await finishRun() });
await db.update(issues).set({ status: "in_progress" }).where(eq(issues.id, issueId));
await refreshIssueContinuationSummary({ db, issueId, agent, run: await finishRun() });
const runId = await seedRun({
companyId,
agentId,
contextSnapshot: {
issueId,
wakeReason: "issue_continuation_needed",
retryReason: "issue_continuation_needed",
},
});
const result = await createPostgresRunDispatchAdapter(db).cancelStaleQueuedRun({
runId,
companyId,
expectedStatus: "queued",
now: new Date(),
});
expect(result).toMatchObject({ outcome: "not_stale" });
});
});
describe("promoteOrCancelDueRetry", () => {