mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-15 18:56:05 +01:00
fix: stop idle execution-control recovery polling (#17094)
Replace idle execution-control polling with workers driven by committed writes and persisted deadlines. Preserve startup recovery, bounded retries, and shutdown safety. Stabilize the Slack setup browser regression by waiting for the restored setup screen before simulating its webhook. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
53732c811b
commit
898144f4b3
26 files changed
+737
-202
No files matched your search
@@ -1,3 +1,6 @@
|
||||
import { DELIVERY_QUEUES } from "../delivery-work-notifications.js";
|
||||
import { writeExecutionControl } from "../execution-control-notifications.js";
|
||||
import { notifyExecutionRunWork } from "../execution-control-notifications.js";
|
||||
import { createRunUsageRecorder } from "../usage-receipts.js";
|
||||
import { applyObservabilityEnvironment, type ProviderObservabilityLaunch } from "@paperclipai/adapter-utils/agent-observability";
|
||||
import { museRunnerBroker } from "../muse-runner-broker.js";
|
||||
@@ -9226,7 +9229,7 @@ async function executePaperclipNativeSessionWithinScope(
|
||||
};
|
||||
const stoppedLeaseRenewal = leaseRenewal.stop().catch(() => undefined);
|
||||
try {
|
||||
await input.db
|
||||
await writeExecutionControl(input.db, DELIVERY_QUEUES.executionFinalization, tx => tx
|
||||
.update(nativeRunFinalizations)
|
||||
.set({
|
||||
controlDeadlineAt: new Date(
|
||||
@@ -9238,7 +9241,7 @@ async function executePaperclipNativeSessionWithinScope(
|
||||
eq(nativeRunFinalizations.runId, input.execution.binding.runId),
|
||||
eq(nativeRunFinalizations.leaseOwner, leaseOwner),
|
||||
),
|
||||
);
|
||||
));
|
||||
|
||||
const failedAtMs = Date.now();
|
||||
const executionFailureMessage = redactIdentityText(
|
||||
@@ -9280,7 +9283,7 @@ async function executePaperclipNativeSessionWithinScope(
|
||||
typeof stopIntent.intentAuditId === "string" && stopIntent.intentAuditId.length > 0 &&
|
||||
["pending", "acknowledged"].includes(String(stopIntent.dispatchState));
|
||||
if (stoppedRun && (pendingStartupStop || hasAcknowledgedNativeStopIntent(stoppedRun) || hasAcknowledgedNativeReassignmentStopIntent(stoppedRun))) {
|
||||
const [settled] = await input.db.update(nativeRunFinalizations).set({
|
||||
const [settled] = await writeExecutionControl(input.db, DELIVERY_QUEUES.executionFinalization, tx => tx.update(nativeRunFinalizations).set({
|
||||
phase: "terminal_failure", failureCode: "native_retry_cancelled", nextAttemptAt: null,
|
||||
leaseOwner: null, leaseExpiresAt: null, controlDeadlineAt: null, recoveryState: null,
|
||||
updatedAt: new Date(),
|
||||
@@ -9290,7 +9293,7 @@ async function executePaperclipNativeSessionWithinScope(
|
||||
eq(nativeRunFinalizations.leaseOwner, leaseOwner),
|
||||
eq(nativeRunFinalizations.attempt, attempt),
|
||||
isNull(nativeRunFinalizations.resultId),
|
||||
)).returning({ runId: nativeRunFinalizations.runId });
|
||||
)).returning({ runId: nativeRunFinalizations.runId }));
|
||||
if (settled) {
|
||||
await stoppedLeaseRenewal;
|
||||
if (warmSessionId !== null && lifecyclePolicy.mode === "warm") {
|
||||
@@ -9377,6 +9380,7 @@ async function executePaperclipNativeSessionWithinScope(
|
||||
),
|
||||
)
|
||||
.for("update");
|
||||
await notifyExecutionRunWork(tx);
|
||||
const updated = await tx
|
||||
.update(nativeRunFinalizations)
|
||||
.set({
|
||||
|
||||
Reference in new issue
Block a user