mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 09:50:48 +01:00
fix(recovery): promote saved input behind a run the fresh continuation replaced
When the fallback continues a task with delivery saved_input, the person's deferred follow-up is the task's next turn. The stranded-queue pass refused to promote it because the replaced native run's finalization is terminal_failure (restart recovery ended it), not committed, and the release path would also have re-blocked the task with a reconciliation incident. Both now skip a run the fallback has superseded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86bc42585b
commit
2588ec1fb8
1 file changed
+9
-2
@@ -18,6 +18,7 @@ import { nativeManualAdmissionHoldsExecution } from "../../../services/native-ru
|
||||
import { and, asc, eq, inArray, isNull, notInArray, or, sql } from "drizzle-orm";
|
||||
import { readReleaseRun, type ReleaseRun } from "./release-run-read.js";
|
||||
import { isGovernancePauseStop } from "../../../services/governance-pause-stop.js";
|
||||
import { agentRunSupersededByFreshContinuation } from "../../../agent-run-cancellation.js";
|
||||
import type { Db } from "@paperclipai/db";
|
||||
import { deliveredQueuedCommentIds, EXTERNAL_CHAT_MESSAGE_WAKE_MUTATION, EXTERNAL_CHAT_MESSAGE_WAKE_REASON } from "../../../services/queued-comment-delivery.js";
|
||||
import { extractIssueReferenceIdentifiers, isUuidLike } from "@paperclipai/shared";
|
||||
@@ -1284,7 +1285,10 @@ export function createPostgresWakeQueueAdapter(db: Db, deps: WakeQueuePostgresAd
|
||||
`,
|
||||
);
|
||||
|
||||
if (input.resumeStrandedQueue && run.runtimeMode === "native") {
|
||||
// A run the fresh-continuation fallback replaced is settled for good: its
|
||||
// finalization may stay terminal_failure (restart recovery ended it), and
|
||||
// the saved input queued behind it is now the task's next turn.
|
||||
if (input.resumeStrandedQueue && run.runtimeMode === "native" && !agentRunSupersededByFreshContinuation(run)) {
|
||||
const [finalized] = contextIssueId && run.nativeIssueId === contextIssueId
|
||||
? await tx.select({ runId: nativeRunFinalizations.runId }).from(nativeRunFinalizations).where(and(
|
||||
eq(nativeRunFinalizations.companyId, input.companyId), eq(nativeRunFinalizations.runId, run.id),
|
||||
@@ -1448,7 +1452,10 @@ export function createPostgresWakeQueueAdapter(db: Db, deps: WakeQueuePostgresAd
|
||||
&& issueRow.status === "blocked" && issueRow.assigneeAgentId === run.agentId) {
|
||||
return { outcome: { kind: "released" }, postCommitEffects: [], run: runSnapshot };
|
||||
}
|
||||
if (!handoffAssigneeAgentId && await recordNativeTerminalRecoveryIfNeeded(tx, run, issueRow, input.now)) {
|
||||
// The fallback already decided this run's continuation; a reconciliation
|
||||
// incident would re-block the task it just released.
|
||||
if (!handoffAssigneeAgentId && !agentRunSupersededByFreshContinuation(run)
|
||||
&& await recordNativeTerminalRecoveryIfNeeded(tx, run, issueRow, input.now)) {
|
||||
return { outcome: { kind: "released" }, postCommitEffects: [], run: runSnapshot };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user