xonecas.io
64875
Mc

mini-coder / commit db0bdc0

fix: suppress ai sdk stderr logging on turn errors

xonecas2026-03-14 db0bdc0e7e4c5f2638b0369654a531fb74ebe740 parent 5807e5e

2 files changed

src/llm-api/turn-request.test.ts+36−0
@@ -0,0 +1,36 @@
1+import { describe, expect, mock, test } from "bun:test";
2+import { buildStreamTextRequest } from "./turn-request.ts";
3+import type { CoreMessage } from "./turn.ts";
4+
5+describe("buildStreamTextRequest", () => {
6+ test("overrides the AI SDK default onError logger", () => {
7+ const request = buildStreamTextRequest({
8+ model: {} as Parameters<typeof buildStreamTextRequest>[0]["model"],
9+ prepared: {
10+ messages: [{ role: "user", content: "hi" }] as CoreMessage[],
11+ systemPrompt: undefined,
12+ pruned: false,
13+ prePruneMessageCount: 1,
14+ postPruneMessageCount: 1,
15+ prePruneTotalBytes: 2,
16+ postPruneTotalBytes: 2,
17+ },
18+ toolSet: {},
19+ onStepFinish: () => {},
20+ signal: undefined,
21+ providerOptions: {},
22+ maxSteps: 50,
23+ });
24+
25+ const originalConsoleError = console.error;
26+ const consoleError = mock(() => {});
27+ console.error = consoleError;
28+ try {
29+ request.onError?.({ error: new Error("boom") });
30+ } finally {
31+ console.error = originalConsoleError;
32+ }
33+
34+ expect(consoleError).not.toHaveBeenCalled();
35+ });
36+});
src/llm-api/turn-request.ts+4−0
@@ -85,6 +85,10 @@ export function buildStreamTextRequest(
8585 }
8686 : {}),
8787 ...(input.signal ? { abortSignal: input.signal } : {}),
88+ onError: () => {
89+ // The AI SDK logs errors to stderr by default. We surface failures through
90+ // streamed turn events so CLI output stays compact and consistent.
91+ },
8892 timeout: { chunkMs: 120_000 },
8993 } as StreamTextOptions;
9094 }