Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): preserve session ownership across handoffs (#3607)

prha56e351061387
diff --git a/.changeset/fix-owner-workflow-handoff.md b/.changeset/fix-owner-workflow-handoff.md
new file mode 100644
index 000000000..0c719c0de
--- /dev/null
+++ b/.changeset/fix-owner-workflow-handoff.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Keep sessions on their original stream across consecutive deployment handoffs. Intermediate handoffs no longer end the session before the final owner completes it, preventing later handoffs from failing with a fatal Workflow SDK `Hook not found` error.
diff --git a/packages/eve/src/execution/session/entry.integration.test.ts b/packages/eve/src/execution/session/entry.integration.test.ts
index fc1f860bc..0069e0f1d 100644
--- a/packages/eve/src/execution/session/entry.integration.test.ts
+++ b/packages/eve/src/execution/session/entry.integration.test.ts
@@ -1436,6 +1436,15 @@ describe("workflowEntry integration", () => {
sessionInboxHookToken(sessionCommandHookToken(anchor.runId)),
);
expect(nextOwner.runId).not.toBe(successor.runId);
+ await vi.waitFor(async () =>
+ expect((await world.runs.get(successor.runId)).status).toBe("completed"),
+ );
+ expect((await world.runs.get(anchor.runId)).status).toBe("running");
+ expect(
+ (await world.steps.list({ runId: successor.runId })).data.some((step) =>
+ step.stepName.endsWith("//signalSessionAnchorStep"),
+ ),
+ ).toBe(false);
if (sessionTimeoutMs !== false && successorTimer !== undefined) {
const nextTimer = await readSessionTimer(nextOwner.runId);
const owner = await world.runs.get(nextOwner.runId);
@@ -1458,7 +1467,27 @@ describe("workflowEntry integration", () => {
}
}
- // Reset ends the session on the successor; the anchor closes the stream once.
+ await waitForParkedTurnStep(nextOwner.runId);
+ await workflowRuntime.dispatchSession({
+ command: followUp("dpl_d", "fifth message", "delivery-e"),
+ sessionId: anchor.runId,
+ });
+ expect((await stream.nextTurn()).at(-1)?.type).toBe("session.waiting");
+ const finalOwner = await waitForCommandHookOwner(
+ sessionInboxHookToken(sessionCommandHookToken(anchor.runId)),
+ );
+ expect(finalOwner.runId).not.toBe(nextOwner.runId);
+ await vi.waitFor(async () =>
+ expect((await world.runs.get(nextOwner.runId)).status).toBe("completed"),
+ );
+ expect((await world.runs.get(anchor.runId)).status).toBe("running");
+ expect(
+ (await world.steps.list({ runId: nextOwner.runId })).data.some((step) =>
+ step.stepName.endsWith("//signalSessionAnchorStep"),
+ ),
+ ).toBe(false);
+
+ // Reset ends the session on the final owner; the anchor closes the stream once.
await workflowRuntime.dispatchSession({
command: { kind: "reset", reason: "handoff test" },
sessionId: anchor.runId,
diff --git a/packages/eve/src/execution/session/program.ts b/packages/eve/src/execution/session/program.ts
index e46c18710..797fe08de 100644
--- a/packages/eve/src/execution/session/program.ts
+++ b/packages/eve/src/execution/session/program.ts
@@ -102,8 +102,8 @@ export async function runPreparedSession(
sessionId: boot.sessionId,
});
let result: WorkflowEntryResult = { output: "", isError: true };
+ let loop: SessionLoopOutcome | undefined;
try {
- let loop: SessionLoopOutcome;
try {
loop = await runSessionLoop(boot, { cursor, handoff, inbox, progress });
} finally {
@@ -131,7 +131,7 @@ export async function runPreparedSession(
}
throw createSafeOuterWorkflowError();
} finally {
- await reportResultToAnchor(boot, result, handoff);
+ await reportResultToAnchor(boot, result, handoff, loop);
}
}
@@ -172,6 +172,7 @@ async function reportResultToAnchor(
boot: SessionBoot,
result: WorkflowEntryResult,
handoff: SessionHandoff,
+ loop: SessionLoopOutcome | undefined,
): Promise<void> {
switch (boot.anchor.kind) {
case "self":
@@ -179,6 +180,7 @@ async function reportResultToAnchor(
await boot.anchor.notify?.(result);
return;
case "successor":
+ if (loop?.kind === "transferred") return;
await signalSessionAnchorStep({ result, token: sessionAnchorToken(boot.sessionId) });
return;
}