Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): hide Workflow SDK logs in the dev TUI and quiet fresh step contention (#4085)

Andrew Barba631122f90ec8
diff --git a/.changeset/quiet-workflow-sdk-logs.md b/.changeset/quiet-workflow-sdk-logs.md
new file mode 100644
index 000000000..c51271ab9
--- /dev/null
+++ b/.changeset/quiet-workflow-sdk-logs.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+The `eve dev` terminal UI now hides Workflow SDK output such as `[workflow-sdk]` lines unless `/loglevel all` is on; the diagnostic log still records every line. eve also no longer warns with "Step execution already in flight in this process" when a queued step delivery loses a normal race with a new inline step.
diff --git a/docs/guides/dev-tui.md b/docs/guides/dev-tui.md
index af95e1feb..eba29cc09 100644
--- a/docs/guides/dev-tui.md
+++ b/docs/guides/dev-tui.md
@@ -118,6 +118,8 @@ Slash commands wait until the turn ends, except `/cancel`, which cancels directl
By default, the UI shows `stderr` logs. Use `/loglevel <all|stderr|sandbox|none>` to change the display; bare `/loglevel` reports the current setting. `Ctrl+L` cycles the same modes.
+Workflow SDK output, such as lines tagged `[workflow-sdk]` or `[world-local]`, reports internal runtime details, so the transcript shows it only in `all` mode.
+
Every `eve dev` process writes diagnostic logs to `.eve/logs/`, regardless of the display mode. Read them with [`eve logs`](../reference/cli#eve-logs).
Use `/traces` to inspect traces recorded during local development. See [Local traces](../observability/otel#local-traces) for trace capture and retention settings.
diff --git a/packages/eve/scripts/vendor-compiled/@workflow/core.mjs b/packages/eve/scripts/vendor-compiled/@workflow/core.mjs
index 4838321a6..bbe9b1022 100644
--- a/packages/eve/scripts/vendor-compiled/@workflow/core.mjs
+++ b/packages/eve/scripts/vendor-compiled/@workflow/core.mjs
@@ -175,31 +175,69 @@ function guardInlineStepExecution() {
return {
name: "eve:guard-inline-step-execution",
transform(source, id) {
- if (!id.replaceAll("\\", "/").endsWith("/@workflow/core/dist/runtime.js")) return null;
-
- // beta.55 only registers recovered inline steps with single-flight.
- // A queued wake can therefore run a newly claimed step again while its
- // original body is still active, especially when a local lease expires.
- // Keep that protection quiet for expected fresh-step contention.
- const unguarded =
- /const executed = s\.lazyStepInput === undefined &&\s+s\.preclaimedStart === undefined\s+\? runStepSingleFlight\(runId, s\.correlationId, run\)\s+: run\(\);/;
- if (!unguarded.test(source)) {
- throw new Error("Recheck the @workflow/core inline step single-flight patch.");
+ const path = id.replaceAll("\\", "/");
+ if (path.endsWith("/@workflow/core/dist/runtime.js")) return guardInlineStepCallSite(source);
+ if (path.endsWith("/@workflow/core/dist/runtime/step-single-flight.js")) {
+ return quietFreshStepContention(source);
}
- return {
- code: source.replace(
- unguarded,
- `const fresh = s.lazyStepInput !== undefined || s.preclaimedStart !== undefined;
+ return null;
+ },
+ };
+}
+
+function guardInlineStepCallSite(source) {
+ // beta.55 only registers recovered inline steps with single-flight.
+ // A queued wake can therefore run a newly claimed step again while its
+ // original body is still active, especially when a local lease expires.
+ // Keep that protection quiet for expected fresh-step contention.
+ const unguarded =
+ /const executed = s\.lazyStepInput === undefined &&\s+s\.preclaimedStart === undefined\s+\? runStepSingleFlight\(runId, s\.correlationId, run\)\s+: run\(\);/;
+ if (!unguarded.test(source)) {
+ throw new Error("Recheck the @workflow/core inline step single-flight patch.");
+ }
+ return {
+ code: source.replace(
+ unguarded,
+ `const fresh = s.lazyStepInput !== undefined || s.preclaimedStart !== undefined;
const executed = s.preclaimedStart?.owned === false
? run()
: runStepSingleFlight(runId, s.correlationId, run, fresh ? "debug" : "warn");`,
- ),
- map: null,
- };
- },
+ ),
+ map: null,
};
}
+// Registering fresh claims above also exposes them to the queued-step call
+// site, which always warns: a concurrent wake replay can publish a step
+// message before the fresh claim's owner stamp lands. Contention with a fresh
+// winner is the same expected wake race, so log it at `debug` whichever call
+// site loses. Recovery-only contention keeps warning. See vercel/workflow#4545.
+function quietFreshStepContention(source) {
+ const edits = [
+ [
+ "const singleFlight = globalSingleton(",
+ 'const freshSteps = globalSingleton("eve//freshStepSingleFlight", 1, () => new Set());\nconst singleFlight = globalSingleton(',
+ ],
+ ["runtimeLogger[logLevel](", 'runtimeLogger[freshSteps.has(key) ? "debug" : logLevel]('],
+ [
+ "singleFlight.inFlight.set(key, promise);",
+ 'singleFlight.inFlight.set(key, promise);\n if (logLevel === "debug") freshSteps.add(key);',
+ ],
+ [
+ "singleFlight.inFlight.delete(key);",
+ "singleFlight.inFlight.delete(key);\n freshSteps.delete(key);",
+ ],
+ ];
+ let code = source;
+ for (const [search, replacement] of edits) {
+ if (code.split(search).length !== 2) {
+ throw new Error("Recheck the @workflow/core step single-flight contention patch.");
+ }
+ code = code.replace(search, replacement);
+ }
+ return { code, map: null };
+}
+
export default {
packageName: "@workflow/core",
compiledPath: "@workflow/core",
diff --git a/packages/eve/src/cli/dev/tui/diagnostic-presentation.ts b/packages/eve/src/cli/dev/tui/diagnostic-presentation.ts
index 0115d2a3e..58dbc9049 100644
--- a/packages/eve/src/cli/dev/tui/diagnostic-presentation.ts
+++ b/packages/eve/src/cli/dev/tui/diagnostic-presentation.ts
@@ -9,6 +9,12 @@ const DIAGNOSTIC_SUMMARY_MAX_CHARACTERS = 240;
*/
const ERROR_HEADLINE_PATTERN = /^\s*(?:message|name):\s*\S|^\s*[A-Z][\w$]*Error\b/u;
+/** A bracket-tagged line such as `[eve:dev] …`, which starts a new log record. */
+const TAGGED_LOG_LINE_PATTERN = /^\[[^\]\s]+\]/u;
+
+/** Tags the vendored Workflow SDK packages put on their console output. */
+const WORKFLOW_LOG_LINE_PATTERN = /^\[(?:workflow(?:-sdk|:[\w:-]+)?|world-[\w-]+)\]/u;
+
type DiagnosticPresentation =
| { readonly kind: "inline"; readonly text: string }
| {
@@ -20,6 +26,27 @@ type DiagnosticPresentation =
readonly path: string;
};
+/**
+ * Splits captured output into ordered Workflow SDK and other segments. A
+ * Workflow SDK record runs until the next tagged line, so its field rows and
+ * stack stay with it. Pass `continuesWorkflow` when the previous chunk ended
+ * inside a Workflow SDK record: pipes can split one record across chunks.
+ */
+export function splitWorkflowLogs(
+ text: string,
+ continuesWorkflow = false,
+): { text: string; workflow: boolean }[] {
+ const segments: { text: string; workflow: boolean }[] = [];
+ let workflow = continuesWorkflow;
+ for (const line of text.split("\n")) {
+ if (TAGGED_LOG_LINE_PATTERN.test(line)) workflow = WORKFLOW_LOG_LINE_PATTERN.test(line);
+ const last = segments.at(-1);
+ if (last?.workflow === workflow) last.text += `\n${line}`;
+ else segments.push({ text: line, workflow });
+ }
+ return segments;
+}
+
/** Chooses whether process diagnostics stay inline or collapse to the local sink. */
export function presentDiagnostic(text: string, path: string): DiagnosticPresentation {
const lines = text.split("\n");
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
index 33299c8ee..ef530c098 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
@@ -3246,6 +3246,54 @@ describe("TerminalRenderer (inline scrollback)", () => {
renderer.shutdown();
});
+ it("shows Workflow SDK stderr only when every log is shown and still records it", () => {
+ const screen = new MockScreen({ columns: 140, rows: 30 });
+ const input = new MockUserInput();
+ const stub = stubDiagnostics();
+ const renderer = new TerminalRenderer({
+ input,
+ output: screen,
+ captureForeignOutput: true,
+ logs: "stderr",
+ unicode: true,
+ diagnostics: stub.diagnostics,
+ });
+ renderer.renderAgentHeader({ name: "Weather Agent", serverUrl: "http://localhost:3000" });
+ const detail = [
+ "[workflow-sdk] Step execution already in flight in this process; awaiting its settlement instead of executing again",
+ " run wrun_01",
+ "[workflow-sdk] Encountered FatalError while executing step",
+ "FatalError: step body threw",
+ " at releaseStep (release-step.ts:1:1)",
+ "[eve:dev] agent reloaded",
+ ].join("\n");
+ // Pipe chunks from the server process can carry several records and can
+ // split one record, even mid-line.
+ const split = detail.indexOf("body threw");
+
+ process.stderr.write(detail.slice(0, split));
+ process.stderr.write(`${detail.slice(split)}\n`);
+
+ const recorded = stub.append.mock.calls
+ .map(([entry]) => entry as { source: string; detail?: string })
+ .filter((entry) => entry.source === "stderr")
+ .map((entry) => entry.detail);
+ expect(recorded.join("\n")).toBe(detail);
+ const hidden = screen.snapshot();
+ expect(hidden).toContain("[eve:dev] agent reloaded");
+ expect(hidden).not.toContain("[workflow-sdk]");
+ expect(hidden).not.toContain("wrun_01");
+ expect(hidden).not.toContain("step body threw");
+
+ renderer.setLogDisplayMode("all");
+ // Adjacent log blocks collapse to the newest, so the split record's tail
+ // proves the hidden segments are revealed.
+ const shown = screen.snapshot();
+ expect(shown).toContain("FatalError: step body threw");
+ expect(shown).toContain("[eve:dev] agent reloaded");
+ renderer.shutdown();
+ });
+
it("subscribes the recorder to log records, displays them, and releases on shutdown", () => {
const screen = new MockScreen({ columns: 120, rows: 30 });
const input = new MockUserInput();
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
index 90687040a..da419cec5 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.ts
@@ -161,7 +161,11 @@ import {
import { renderQuestionChoices, renderQuestionPanel } from "./question-panel.js";
import { TurnClock } from "./turn-clock.js";
import { MessageQueue, renderMessageQueueRows } from "./message-queue.js";
-import { formatStoredDiagnostic, presentDiagnostic } from "./diagnostic-presentation.js";
+import {
+ formatStoredDiagnostic,
+ presentDiagnostic,
+ splitWorkflowLogs,
+} from "./diagnostic-presentation.js";
import { reduceSetupSelectInput, setupSelectionIntent } from "./setup-selection-input.js";
import {
isProgressPulseVisible,
@@ -612,6 +616,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
#restoreLogCapture?: () => void;
#stdoutLogBuffer = "";
#stderrLogBuffer = "";
+ #stderrInWorkflowLog = false;
#delayedDevBuildError?: string;
/**
* The in-place dev rebuild status line. While the dev server's rebuild log
@@ -5025,6 +5030,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
this.#stdoutLogBuffer = "";
this.#stderrLogBuffer = "";
+ this.#stderrInWorkflowLog = false;
const capture = (target: NodeJS.WriteStream, source: "stdout" | "stderr"): (() => void) => {
const original = target.write.bind(target);
@@ -5085,7 +5091,7 @@ export class TerminalRenderer implements AgentTUIRenderer {
*/
#displayLogRecord(record: LogRecord): void {
const fieldsText = record.fields === undefined ? "" : ` ${JSON.stringify(record.fields)}`;
- this.#handleCapturedStderr(`[eve:${record.namespace}] ${record.message}${fieldsText}`);
+ this.#presentCapturedStderr(`[eve:${record.namespace}] ${record.message}${fieldsText}`);
this.#paint();
}
@@ -5164,7 +5170,30 @@ export class TerminalRenderer implements AgentTUIRenderer {
flushPending();
}
+ /**
+ * Workflow SDK output is framework-internal and not actionable for users, so
+ * it shows only under `/loglevel all`; the diagnostic log keeps every line.
+ */
#handleCapturedStderr(content: string): void {
+ const segments = splitWorkflowLogs(content, this.#stderrInWorkflowLog);
+ this.#stderrInWorkflowLog = segments.at(-1)?.workflow ?? this.#stderrInWorkflowLog;
+ for (const segment of segments) {
+ if (segment.text.trim().length === 0) continue;
+ if (!segment.workflow) {
+ this.#presentCapturedStderr(segment.text);
+ continue;
+ }
+ this.#pushBlock({
+ kind: "log",
+ title: "stderr",
+ body: segment.text,
+ logVisibility: "all-only",
+ live: true,
+ });
+ }
+ }
+
+ #presentCapturedStderr(content: string): void {
const lines = content.split("\n");
const failedIndex = lines.findIndex((line) => {
return parseDevRebuildLogLine(line.trimEnd())?.kind === "failed";
diff --git a/packages/eve/test/scenarios/steering.scenario.test.ts b/packages/eve/test/scenarios/steering.scenario.test.ts
index 7a3fe70a5..a702bb0ab 100644
--- a/packages/eve/test/scenarios/steering.scenario.test.ts
+++ b/packages/eve/test/scenarios/steering.scenario.test.ts
@@ -45,6 +45,9 @@ export default defineAgent({
// A one-second lease expires mid-step, so the ownership backstop
// races the child wakes into the single-flight guard.
WORKFLOW_INLINE_OWNERSHIP_LEASE_SECONDS: "1",
+ // Contention with a fresh claim logs at debug, which the Workflow SDK
+ // prints to stdout only for a matching namespace.
+ DEBUG: "workflow:runtime:debug",
},
});
try {
@@ -65,7 +68,9 @@ export default defineAgent({
),
).toHaveLength(5);
expect(events.filter((event) => event.type === "turn.completed")).toHaveLength(1);
- expect(server.stderr()).toContain("Step execution already in flight in this process");
+ expect(`${server.stdout()}${server.stderr()}`).toContain(
+ "Step execution already in flight in this process",
+ );
} finally {
await server.stop();
}
diff --git a/packages/eve/test/workflow-inline-step-execution.test.ts b/packages/eve/test/workflow-inline-step-execution.test.ts
index c812d01c9..36199914d 100644
--- a/packages/eve/test/workflow-inline-step-execution.test.ts
+++ b/packages/eve/test/workflow-inline-step-execution.test.ts
@@ -11,6 +11,32 @@ const executed = s.lazyStepInput === undefined &&
return executed;
`;
+const beta57StepSingleFlight = `
+const singleFlight = globalSingleton('@workflow/core//stepSingleFlight', 1, () => ({ inFlight: new Map() }));
+async function runStepSingleFlight(runId, correlationId, execute, logLevel = 'warn') {
+ const key = \`\${runId}:\${correlationId}\`;
+ const existing = singleFlight.inFlight.get(key);
+ if (existing) {
+ runtimeLogger[logLevel]('Step execution already in flight in this process', { workflowRunId: runId, stepId: correlationId });
+ try {
+ await existing;
+ }
+ catch {
+ }
+ return { type: 'skipped' };
+ }
+ const promise = execute();
+ singleFlight.inFlight.set(key, promise);
+ try {
+ return await promise;
+ }
+ finally {
+ singleFlight.inFlight.delete(key);
+ }
+}
+return runStepSingleFlight;
+`;
+
type StepResult = { type: "completed" | "skipped" };
type VendorPlugin = {
@@ -31,6 +57,30 @@ function transformInlineStepExecution(source: string) {
return transformed.code;
}
+function loadStepSingleFlight() {
+ const transformed = inlineStepPlugin?.transform?.(
+ beta57StepSingleFlight,
+ "/workspace/node_modules/@workflow/core/dist/runtime/step-single-flight.js",
+ );
+ if (!transformed) throw new Error("Failed to transform the step single-flight module.");
+ const logLevels: string[] = [];
+ const runtimeLogger = {
+ debug: () => logLevels.push("debug"),
+ warn: () => logLevels.push("warn"),
+ };
+ const globalSingleton = (_name: string, _version: number, create: () => unknown) => create();
+ const runStepSingleFlight = new Function("globalSingleton", "runtimeLogger", transformed.code)(
+ globalSingleton,
+ runtimeLogger,
+ ) as (
+ runId: string,
+ correlationId: string,
+ execute: () => Promise<StepResult>,
+ logLevel?: string,
+ ) => Promise<StepResult>;
+ return { logLevels, runStepSingleFlight };
+}
+
function deferred() {
let resolve!: () => void;
const promise = new Promise<void>((resolvePromise) => {
@@ -177,4 +227,37 @@ describe("inline step single-flight vendoring patch", () => {
expect(executions).toBe(1);
expect(singleFlight.logLevels).toEqual([]);
});
+
+ it("quiets queued deliveries that lose to a fresh claim and keeps recovery warnings", async () => {
+ const { logLevels, runStepSingleFlight } = loadStepSingleFlight();
+
+ async function contend(winnerLogLevel: string) {
+ const release = deferred();
+ let executions = 0;
+ const winner = runStepSingleFlight(
+ "run",
+ "step",
+ async () => {
+ executions += 1;
+ await release.promise;
+ return { type: "completed" };
+ },
+ winnerLogLevel,
+ );
+ // Queued step deliveries call single-flight without a log level.
+ const queued = runStepSingleFlight("run", "step", async () => {
+ executions += 1;
+ return { type: "completed" };
+ });
+ release.resolve();
+ await expect(winner).resolves.toEqual({ type: "completed" });
+ await expect(queued).resolves.toEqual({ type: "skipped" });
+ expect(executions).toBe(1);
+ }
+
+ await contend("debug");
+ await contend("warn");
+
+ expect(logLevels).toEqual(["debug", "warn"]);
+ });
});