mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
fix: retain recovery handling for startup Stop deadlines
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
c9e95797d7
commit
74bd68d8be
4 files changed
+10
-5
No files matched your search
@@ -4984,7 +4984,7 @@ describe("native session cancellation", () => {
|
||||
// Let the durable intent commit before advancing the startup deadline.
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
await vi.advanceTimersByTimeAsync(30_000);
|
||||
expect(await stopping).toMatchObject({ message: "native_cancellation_startup_not_ready" });
|
||||
expect(await stopping).toMatchObject({ name: "NativeCancellationPendingRecoveryError" });
|
||||
expect(persistence.getResultJson().nativeCancellation).toMatchObject({ dispatchState: "pending" });
|
||||
vi.useRealTimers();
|
||||
open(); await outcome;
|
||||
|
||||
@@ -219,7 +219,10 @@ function detachActiveNativeSessionForRestart(active: ActiveNativeSession) {
|
||||
return active.restartDetach;
|
||||
}
|
||||
|
||||
async function waitForNativeSessionStartup(runId: string, failureCode = "native_restart_startup_not_ready") {
|
||||
async function waitForNativeSessionStartup(
|
||||
runId: string,
|
||||
timeoutError: () => Error = () => new Error("native_restart_startup_not_ready"),
|
||||
) {
|
||||
const startup = nativeSessionStartups.get(runId);
|
||||
if (!startup) return null;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
@@ -227,7 +230,7 @@ async function waitForNativeSessionStartup(runId: string, failureCode = "native_
|
||||
return await Promise.race([
|
||||
startup.promise,
|
||||
new Promise<never>((_resolve, reject) => {
|
||||
timer = setTimeout(() => reject(new Error(failureCode)), 30_000);
|
||||
timer = setTimeout(() => reject(timeoutError()), 30_000);
|
||||
}),
|
||||
]);
|
||||
} finally {
|
||||
@@ -6577,7 +6580,7 @@ export async function cancelNativeSession(
|
||||
}
|
||||
try {
|
||||
const active = activeNativeSessions.get(runId) ??
|
||||
(startup ? await waitForNativeSessionStartup(runId, "native_cancellation_startup_not_ready") : null);
|
||||
(startup ? await waitForNativeSessionStartup(runId, () => new NativeCancellationPendingRecoveryError()) : null);
|
||||
let dispatched = false;
|
||||
if (active) {
|
||||
dispatched = true;
|
||||
|
||||
@@ -29,6 +29,7 @@ describe("agent chat hardening oracles", () => {
|
||||
const valid = { reply: "RUN-2 is blocked on VENUE123.", expectedIssueIdentifier: "RUN-2", blocker: "VENUE123", staleBlocker: "BUDGET123",
|
||||
before, after: before, taskIdsBefore: ["task"], taskIdsAfter: ["task"], taskRuns: [] };
|
||||
expect(() => assertGroundedChatStatus(valid)).not.toThrow();
|
||||
expect(() => assertGroundedChatStatus({ ...valid, reply: "RUN-2 is blocked on VENUE123. BUDGET123 was resolved." })).not.toThrow();
|
||||
expect(() => assertGroundedChatStatus({ ...valid, reply: "RUN-2 is blocked on BUDGET123." })).toThrow();
|
||||
expect(() => assertGroundedChatStatus({ ...valid, after: task })).toThrow();
|
||||
expect(() => assertGroundedChatStatus({ ...valid, taskRuns: [run] })).toThrow();
|
||||
|
||||
@@ -42,7 +42,8 @@ export function assertGroundedChatStatus(input: {
|
||||
expect(input.reply).toContain(input.expectedIssueIdentifier);
|
||||
expect(input.reply).toMatch(/blocked/i);
|
||||
expect(input.reply).toContain(input.blocker);
|
||||
expect(input.reply).not.toContain(input.staleBlocker);
|
||||
// A correct answer may explain that the old blocker was resolved. Require
|
||||
// the current label rather than rejecting that useful historical context.
|
||||
expect(input.after).toMatchObject({ id: input.before.id, status: "blocked", assigneeAgentId: input.before.assigneeAgentId });
|
||||
expect([...input.taskIdsAfter].sort()).toEqual([...input.taskIdsBefore].sort());
|
||||
expect(input.taskRuns).toHaveLength(0);
|
||||
|
||||
Reference in new issue
Block a user