Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): default Vercel workflow events to the ws transport (#4233)

Andrew Barbabeb0dd17bb78
diff --git a/.changeset/vercel-ws-events-transport.md b/.changeset/vercel-ws-events-transport.md
new file mode 100644
index 000000000..c329917dc
--- /dev/null
+++ b/.changeset/vercel-ws-events-transport.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Agents on the Vercel workflow world now write workflow events over WebSocket by default (`WORKFLOW_EVENTS_TRANSPORT=ws`). Set `WORKFLOW_EVENTS_TRANSPORT=http` to keep the HTTP transport.
diff --git a/packages/eve/src/internal/workflow/vercel-world-defaults.test.ts b/packages/eve/src/internal/workflow/vercel-world-defaults.test.ts
index cb40d8c37..345eac56c 100644
--- a/packages/eve/src/internal/workflow/vercel-world-defaults.test.ts
+++ b/packages/eve/src/internal/workflow/vercel-world-defaults.test.ts
@@ -6,14 +6,26 @@ describe("applyVercelWorkflowWorldDefaults", () => {
it("batches event bursts without changing the world's other settings", () => {
const streams = {};
const world: { streams: object; streamFlushIntervalMs?: number } = { streams };
- applyVercelWorkflowWorldDefaults(world);
+ applyVercelWorkflowWorldDefaults(world, {});
expect(world).toEqual({ streams, streamFlushIntervalMs: 10 });
expect(world.streams).toBe(streams);
});
it.each([0, 5, 25])("preserves an explicit %i ms window", (streamFlushIntervalMs) => {
const world = { streamFlushIntervalMs };
- applyVercelWorkflowWorldDefaults(world);
+ applyVercelWorkflowWorldDefaults(world, {});
expect(world.streamFlushIntervalMs).toBe(streamFlushIntervalMs);
});
+
+ it.each([undefined, ""])("defaults the events transport to ws when unset (%j)", (value) => {
+ const env: Record<string, string | undefined> = { WORKFLOW_EVENTS_TRANSPORT: value };
+ applyVercelWorkflowWorldDefaults({}, env);
+ expect(env.WORKFLOW_EVENTS_TRANSPORT).toBe("ws");
+ });
+
+ it("preserves an operator-supplied events transport", () => {
+ const env = { WORKFLOW_EVENTS_TRANSPORT: "http" };
+ applyVercelWorkflowWorldDefaults({}, env);
+ expect(env.WORKFLOW_EVENTS_TRANSPORT).toBe("http");
+ });
});
diff --git a/packages/eve/src/internal/workflow/vercel-world-defaults.ts b/packages/eve/src/internal/workflow/vercel-world-defaults.ts
index afec70685..8647e46ee 100644
--- a/packages/eve/src/internal/workflow/vercel-world-defaults.ts
+++ b/packages/eve/src/internal/workflow/vercel-world-defaults.ts
@@ -1,6 +1,15 @@
/** Configure the freshly constructed built-in Vercel World before installation. */
-export function applyVercelWorkflowWorldDefaults(world: { streamFlushIntervalMs?: number }): void {
+export function applyVercelWorkflowWorldDefaults(
+ world: { streamFlushIntervalMs?: number },
+ env: Record<string, string | undefined> = process.env as Record<string, string | undefined>,
+): void {
// Lifecycle events arrive across several async handlers; a short window lets
// each burst share a network write. The SDK's explicit env override still wins.
world.streamFlushIntervalMs ??= 10;
+
+ // world-vercel reads this gate on every event write, so the default applies
+ // even though it is set after construction. Operators opt out with `http`.
+ if (env.WORKFLOW_EVENTS_TRANSPORT === undefined || env.WORKFLOW_EVENTS_TRANSPORT === "") {
+ env.WORKFLOW_EVENTS_TRANSPORT = "ws";
+ }
}