From 95cf296f3782d26a48ae898e20ccfd9d09508637 Mon Sep 17 00:00:00 2001 From: Eli Fayerman Date: Mon, 4 May 2026 12:40:19 -0400 Subject: [PATCH] fix claude raw stream logging --- backend/src/lib/llm/claude.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/src/lib/llm/claude.ts b/backend/src/lib/llm/claude.ts index 9ed625eb..ee62de82 100644 --- a/backend/src/lib/llm/claude.ts +++ b/backend/src/lib/llm/claude.ts @@ -1,7 +1,5 @@ import Anthropic from "@anthropic-ai/sdk"; import type { Tool } from "@anthropic-ai/sdk/resources/messages/messages"; -import * as fs from "fs"; -import * as path from "path"; import type { StreamChatParams, StreamChatResult, @@ -10,10 +8,7 @@ import type { } from "./types"; import { toClaudeTools } from "./tools"; -const RAW_STREAM_LOG_PATH = path.resolve( - process.cwd(), - "claude-raw-stream.log", -); +const DEBUG_LLM_STREAM = process.env.DEBUG_LLM_STREAM === "true"; type ContentBlock = | { type: "text"; text: string } @@ -81,9 +76,9 @@ export async function streamClaude( let sawThinking = false; stream.on("streamEvent", (event) => { - const line = JSON.stringify(event); - console.log("[claude raw stream]", line); - fs.appendFile(RAW_STREAM_LOG_PATH, line + "\n", () => {}); + if (DEBUG_LLM_STREAM) { + console.debug("[claude raw stream]", JSON.stringify(event)); + } }); stream.on("text", (delta) => {