From 55c7f1cd9c001dcdb195bf9c0fdea9ab9dfe03ef Mon Sep 17 00:00:00 2001 From: chenkangqiang Date: Thu, 12 Feb 2026 10:25:40 +0800 Subject: [PATCH] fix: thinking block parse --- .../claude/agent/sdk/parsing/MessageParser.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/claude-code-sdk/src/main/java/org/springaicommunity/claude/agent/sdk/parsing/MessageParser.java b/claude-code-sdk/src/main/java/org/springaicommunity/claude/agent/sdk/parsing/MessageParser.java index 1b1e92fc..c53027f6 100644 --- a/claude-code-sdk/src/main/java/org/springaicommunity/claude/agent/sdk/parsing/MessageParser.java +++ b/claude-code-sdk/src/main/java/org/springaicommunity/claude/agent/sdk/parsing/MessageParser.java @@ -164,6 +164,7 @@ private List parseContentBlocks(JsonNode arrayNode) throws Message case "text" -> parseTextBlock(blockNode); case "tool_use" -> parseToolUseBlock(blockNode); case "tool_result" -> parseToolResultBlock(blockNode); + case "thinking" -> parseThinkingBlock(blockNode); default -> throw new MessageParseException("Unknown content block type: " + type); }; @@ -226,6 +227,15 @@ else if (content instanceof List) { return builder.build(); } + private ThinkingBlock parseThinkingBlock(JsonNode node) throws MessageParseException { + String thinking = getStringField(node, "thinking"); + if (thinking == null) { + throw new MessageParseException("Missing 'thinking' field in thinking block"); + } + String signature = getStringField(node, "signature"); + return ThinkingBlock.of(thinking, signature); + } + private Map parseDataMap(JsonNode node) { Map map = new HashMap<>(); node.fields().forEachRemaining(entry -> {