From a2ea1acd3e6374a80a4c6390469d05c44a9f0230 Mon Sep 17 00:00:00 2001 From: fernando234234 Date: Fri, 9 Jan 2026 18:33:56 +0100 Subject: [PATCH] fix(claude-code): prevent reasoning text duplication The thinking_complete handler was re-emitting the full reasoning text after it had already been streamed via reasoning chunks. This caused the reasoning content to appear twice in the UI. Now the thinking_complete case only captures the signature for tool use continuations without re-emitting the text. --- src/api/providers/claude-code.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/api/providers/claude-code.ts b/src/api/providers/claude-code.ts index f2bccc329c..b6c9e94904 100644 --- a/src/api/providers/claude-code.ts +++ b/src/api/providers/claude-code.ts @@ -219,17 +219,12 @@ export class ClaudeCodeHandler implements ApiHandler, SingleCompletionHandler { case "thinking_complete": // Capture the signature for persistence in api_conversation_history // This enables tool use continuations where thinking blocks must be passed back + // NOTE: We do NOT emit the text here because it was already streamed via + // "reasoning" chunks. Re-emitting would duplicate the reasoning in the UI. + // The signature is retrieved via getThoughtSignature() after streaming completes. if (chunk.signature) { this.lastThinkingSignature = chunk.signature } - // Emit a complete thinking block with signature - // This is critical for interleaved thinking with tool use - // The signature must be included when passing thinking blocks back to the API - yield { - type: "reasoning", - text: chunk.thinking, - signature: chunk.signature, - } break case "tool_call_partial":