Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): ignore sandbox records saved before the provider redesign (#4336)

e0-gh-vercel-connect[bot]8c026ee6826f
diff --git a/.changeset/legacy-sandbox-record.md b/.changeset/legacy-sandbox-record.md
new file mode 100644
index 000000000..d5894a411
--- /dev/null
+++ b/.changeset/legacy-sandbox-record.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Sessions saved before eve 0.64 that used a sandbox no longer fail every sandbox call with `Sandbox session state belongs to provider "undefined"` or the `Session checkpoint sandbox provider state is incompatible` handoff error. A sandbox record without a provider is treated as no sandbox, so the next sandbox call starts a fresh one.
diff --git a/packages/eve/src/execution/sandbox/ensure.test.ts b/packages/eve/src/execution/sandbox/ensure.test.ts
index 84f881cf5..d4e23e729 100644
--- a/packages/eve/src/execution/sandbox/ensure.test.ts
+++ b/packages/eve/src/execution/sandbox/ensure.test.ts
@@ -2,6 +2,8 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { shutdownActiveSandboxHandles } from "#execution/sandbox/active-handles.js";
import { ContextContainer, contextStorage } from "#context/container.js";
import { SessionKey } from "#context/keys.js";
+import { readDurableSession } from "#execution/durable-session-store.js";
+import { importConversation, readLegacySnapshot } from "#execution/legacy-session/snapshot.js";
import { ensureSandboxAccess } from "#execution/sandbox/ensure.js";
import { mockSandbox } from "#internal/testing/mocks/mock-sandbox.js";
import { defineParentSandbox, defineSandbox } from "#public/definitions/sandbox.js";
@@ -140,6 +142,43 @@ describe("ensureSandboxAccess", () => {
expect(value.create).toHaveBeenCalledOnce();
});
+ it("starts a fresh sandbox for a session imported from eve 0.54", async () => {
+ const setup = vi.fn();
+ const value = fixture(setup);
+ const imported = importConversation(
+ readLegacySnapshot({
+ sessionId: "session-1",
+ snapshot: {
+ version: 1,
+ session: {
+ sessionId: "session-1",
+ continuationToken: "http:legacy",
+ history: [],
+ agent: { system: "" },
+ // eve 0.54 persisted a backend reconnect record, not provider state.
+ sandboxState: {
+ initialized: true,
+ session: {
+ backendName: "test",
+ metadata: { sandboxId: "sbx_old" },
+ sessionKey: "old",
+ },
+ },
+ },
+ },
+ }),
+ );
+
+ await open(
+ value.registry,
+ "session-1",
+ readDurableSession(imported.sessionState).sandboxState ?? null,
+ );
+
+ expect(setup).toHaveBeenCalledOnce();
+ expect(value.start).toHaveBeenCalledOnce();
+ });
+
it("passes empty live options when a child inherits its parent sandbox", async () => {
const value = fixture();
diff --git a/packages/eve/src/execution/sandbox/ensure.ts b/packages/eve/src/execution/sandbox/ensure.ts
index cd9664ba5..bf2adadcd 100644
--- a/packages/eve/src/execution/sandbox/ensure.ts
+++ b/packages/eve/src/execution/sandbox/ensure.ts
@@ -51,7 +51,11 @@ interface OpenedSandbox {
const pendingSandboxStarts = new Map<string, Promise<SandboxSessionState | null>>();
export async function ensureSandboxAccess(input: EnsureSandboxAccessInput): Promise<SandboxAccess> {
- let persisted: SandboxSessionState | null = input.state?.session ?? null;
+ // Sessions saved before the provider redesign (eve 0.64) hold a backend
+ // record with no `providerName`. No provider can resume it, so treat it as
+ // no sandbox and let the selector start a fresh one.
+ let persisted: SandboxSessionState | null =
+ input.state?.session?.providerName === undefined ? null : input.state.session;
let opened: OpenedSandbox | undefined;
let opening: Promise<SandboxProviderHandle> | undefined;
let requiring: Promise<SandboxProviderHandle> | undefined;
diff --git a/packages/eve/src/execution/session/handoff-steps.test.ts b/packages/eve/src/execution/session/handoff-steps.test.ts
index 9376be5a0..8527b8af4 100644
--- a/packages/eve/src/execution/session/handoff-steps.test.ts
+++ b/packages/eve/src/execution/session/handoff-steps.test.ts
@@ -45,6 +45,18 @@ describe("validateSessionCheckpointStep", () => {
expect(readDurableSessionMock).toHaveBeenCalledWith(checkpoint.sessionState);
});
+ it("ignores a sandbox record saved before the provider redesign", async () => {
+ deserializeContextMock.mockResolvedValue({ require: vi.fn() });
+ readDurableSessionMock.mockReturnValue({
+ sandboxState: {
+ initialized: true,
+ session: { backendName: "vercel", sessionKey: "old", metadata: {} },
+ },
+ });
+
+ await expect(validate(createCheckpoint())).resolves.toEqual({ kind: "valid" });
+ });
+
it("rejects an incompatible workflow tool run with the current checkpoint version", async () => {
deserializeContextMock.mockResolvedValue({ require: vi.fn() });
readDurableSessionMock.mockReturnValue({
diff --git a/packages/eve/src/execution/session/handoff-steps.ts b/packages/eve/src/execution/session/handoff-steps.ts
index f8b039fd1..96359ae75 100644
--- a/packages/eve/src/execution/session/handoff-steps.ts
+++ b/packages/eve/src/execution/session/handoff-steps.ts
@@ -99,7 +99,13 @@ export async function validateSessionCheckpointStep(input: {
const bundle = context.require(BundleKey);
const session = readDurableSession(checkpoint.sessionState);
const sandboxState = session.sandboxState?.session;
- if (sandboxState !== null && sandboxState !== undefined) {
+ // A record without `providerName` predates the provider redesign (eve 0.64)
+ // and is ignored at runtime, so it must not block the handoff.
+ if (
+ sandboxState !== null &&
+ sandboxState !== undefined &&
+ sandboxState.providerName !== undefined
+ ) {
const definition =
getResolvedRuntimeAgentNode(bundle.graph, bundle.nodeId).sandboxRegistry.sandbox.inheritance
?.definition ??