The Open Framework for Building Agents
fix(eve): security - keep workflow failures private (#1124)
Andrew Barba4d3748d763f3
diff --git a/.changeset/private-workflow-failures.md b/.changeset/private-workflow-failures.mdnew file mode 100644index 000000000..48b093428--- /dev/null+++ b/.changeset/private-workflow-failures.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Keep raw outer workflow failure details in the private session trace instead of copying them into provider logs and Workflow telemetry.diff --git a/packages/eve/src/execution/terminal-session-failure-step.ts b/packages/eve/src/execution/terminal-session-failure-step.tsindex 3a7735cdc..080fcea36 100644--- a/packages/eve/src/execution/terminal-session-failure-step.ts+++ b/packages/eve/src/execution/terminal-session-failure-step.ts@@ -21,8 +21,8 @@ export async function emitTerminalSessionFailureStep(input: {"use step";// Cataloged failures replace the raw identity with the curated one; the- // `detail` dump stays attached so the local diagnostic log keeps the- // raw evidence while the transcript shows the actionable summary.+ // `detail` dump stays attached to the private event so the session trace+ // keeps the raw evidence while the transcript shows the actionable summary.const formatted = formatError(input.error);const summary = summarizeKnownError(input.error);let details = formatted;@@ -43,9 +43,6 @@ export async function emitTerminalSessionFailureStep(input: {sessionId,errorId: typeof details.errorId === "string" ? details.errorId : undefined,code,- message,- hint: summary?.hint,- detail: typeof details.detail === "string" ? details.detail : undefined,});const event = createSessionFailedEvent({ code, details, message, sessionId });diff --git a/packages/eve/src/execution/workflow-entry.integration.test.ts b/packages/eve/src/execution/workflow-entry.integration.test.tsindex 0c61a0693..7fa48d882 100644--- a/packages/eve/src/execution/workflow-entry.integration.test.ts+++ b/packages/eve/src/execution/workflow-entry.integration.test.ts@@ -337,7 +337,9 @@ describe("workflowEntry integration", () => {(event) => event.type === "message.completed" || event.type === "turn.started",),).toBe(false);- await expect(contender.returnValue).rejects.toThrow(/Hook token/);+ await expect(contender.returnValue).rejects.toThrow(+ /Agent workflow failed\. Inspect the private session trace for details\./,+ );await resumeHook(continuationToken, {kind: "deliver",diff --git a/packages/eve/src/execution/workflow-entry.test.ts b/packages/eve/src/execution/workflow-entry.test.tsindex 0170f6b71..f17458aec 100644--- a/packages/eve/src/execution/workflow-entry.test.ts+++ b/packages/eve/src/execution/workflow-entry.test.ts@@ -182,11 +182,19 @@ describe("workflowEntry", () => {serializedContext: createSerializedContext(),}),).rejects.toMatchObject({- conflictingRunId: "wrun_owner",- name: "HookConflictError",- token: "http:test",+ message: "Agent workflow failed. Inspect the private session trace for details.",+ name: "EveWorkflowFailure",});+ expect(emitTerminalSessionFailureStep).toHaveBeenCalledWith(+ expect.objectContaining({+ error: expect.objectContaining({+ conflictingRunId: "wrun_owner",+ name: "HookConflictError",+ token: "http:test",+ }),+ }),+ );expect(dispatchTurnStep).not.toHaveBeenCalled();expect(dispose).toHaveBeenCalledOnce();});@@ -218,12 +226,19 @@ describe("workflowEntry", () => {serializedContext: createSerializedContext(),}),).rejects.toMatchObject({- conflictingRunId: undefined,- message: 'Hook token "http:test" is already in use',- name: "HookConflictError",- token: "http:test",+ message: "Agent workflow failed. Inspect the private session trace for details.",+ name: "EveWorkflowFailure",});+ expect(emitTerminalSessionFailureStep).toHaveBeenCalledWith(+ expect.objectContaining({+ error: expect.objectContaining({+ message: 'Hook token "http:test" is already in use',+ name: "HookConflictError",+ token: "http:test",+ }),+ }),+ );expect(dispatchTurnStep).not.toHaveBeenCalled();expect(dispose).toHaveBeenCalledOnce();});@@ -299,9 +314,16 @@ describe("workflowEntry", () => {input: { message: "delegate" },serializedContext,}),- ).rejects.toThrow("persistent recoverable failure");+ ).rejects.toMatchObject({+ message: "Agent workflow failed. Inspect the private session trace for details.",+ name: "EveWorkflowFailure",+ });- expect(emitTerminalSessionFailureStep).toHaveBeenCalledOnce();+ expect(emitTerminalSessionFailureStep).toHaveBeenCalledWith(+ expect.objectContaining({+ error: expect.objectContaining({ message: "persistent recoverable failure" }),+ }),+ );expect(fireSessionCallbackStep).toHaveBeenCalledOnce();expect(notifyDelegatedParentStep).toHaveBeenCalledOnce();expect(notifyDelegatedParentStep).toHaveBeenCalledWith({diff --git a/packages/eve/src/execution/workflow-entry.ts b/packages/eve/src/execution/workflow-entry.tsindex ab3c2489b..3af4d4127 100644--- a/packages/eve/src/execution/workflow-entry.ts+++ b/packages/eve/src/execution/workflow-entry.ts@@ -32,6 +32,9 @@ import {} from "#execution/session-delivery-hook.js";import { readSerializedSubagentDepth } from "#harness/subagent-depth.js";+const SAFE_OUTER_WORKFLOW_FAILURE_MESSAGE =+ "Agent workflow failed. Inspect the private session trace for details.";+// workflow-entry.ts is the durable workflow body — the bundler rejects// node built-ins here, so `internal/logging.ts` cannot be imported.// Error logging happens inside `emitTerminalSessionFailureStep`.@@ -139,10 +142,16 @@ export async function workflowEntry(input: WorkflowEntryInput): Promise<Workflowresult: createDelegatedSubagentErrorResult(input.serializedContext, error),serializedContext: input.serializedContext,});- throw error;+ throw createSafeOuterWorkflowError();}}+function createSafeOuterWorkflowError(): Error {+ const error = new Error(SAFE_OUTER_WORKFLOW_FAILURE_MESSAGE);+ error.name = "EveWorkflowFailure";+ return error;+}+async function runDriverLoop(input: {readonly capabilities?: SessionCapabilities;readonly driverWritable: WritableStream<Uint8Array>;diff --git a/packages/eve/src/execution/workflow-steps.test.ts b/packages/eve/src/execution/workflow-steps.test.tsindex 5b5180e49..87d833269 100644--- a/packages/eve/src/execution/workflow-steps.test.ts+++ b/packages/eve/src/execution/workflow-steps.test.ts@@ -1193,10 +1193,12 @@ describe("emitTerminalSessionFailureStep", () => {// raw Errors to this shape (`normalizeSerializableError`) before// handing them into the step so they survive JSON serialization.const error = {- message: "attachment staging failed",+ detail: "private attachment name: confidential.png",+ message: "attachment staging failed for confidential.png",name: "EveAttachmentError",kind: "resolver-threw",};+ const errorLog = vi.spyOn(console, "error").mockImplementation(() => {});await emitTerminalSessionFailureStep({error,@@ -1209,9 +1211,19 @@ describe("emitTerminalSessionFailureStep", () => {data: { code: string; message: string; details?: { errorId?: string } };};expect(data.code).toBe("EveAttachmentError");- expect(data.message).toContain("attachment staging failed");+ expect(data.message).toContain("attachment staging failed for confidential.png");expect(typeof data.details?.errorId).toBe("string");+ const providerLog = errorLog.mock.calls.find(([line]) =>+ String(line).includes("workflow loop threw"),+ );+ expect(providerLog?.[1]).toEqual({+ code: "EveAttachmentError",+ errorId: data.details?.errorId,+ sessionId: "session-terminal",+ });+ expect(JSON.stringify(providerLog)).not.toContain("confidential.png");+// The terminal step must also write the event to the durable// stream so event-stream consumers see a canonical tail instead// of an abrupt close.@@ -1254,8 +1266,8 @@ describe("emitTerminalSessionFailureStep", () => {expect(data.message).toContain("ECONNREFUSED");expect(data.details?.semanticErrorId).toBe("network-request-failed");expect(data.details?.hint).toContain("Check your internet connection");- // The raw inspection stays attached so the diagnostic log keeps the- // evidence the curated message summarizes away.+ // The raw inspection stays attached so the private session trace keeps+ // the evidence the curated message summarizes away.expect(data.details?.detail).toContain("fetch failed");});