Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai, ai-anthropic): send redacted thinking and tool errors back to Claude #1579

MergedAlemTuzlakmerged 4 commits intomain fromrefs/pull/1579/headmerged by AlemTuzlak View on GitHub

Showing 16 changed files with 16 additions and 1 deletion (loading 12).

x
0 of 16 viewed, 16 left
12 additions and 0 deletions.changeset/anthropic-thinking-replay.mdAdded
View file
@@ -0,0 +1,12 @@
+---
+'@tanstack/ai': patch
+'@tanstack/ai-anthropic': patch
+---
+​
+Send Claude's thinking and tool errors back the way Claude sent them.
+​
+- A tool message with `error` now sends `tool_result.is_error: true`, so Claude sees that the tool failed.
+- A `redacted_thinking` block is no longer dropped. It becomes a thinking part with `redacted: true`, an empty `content`, and the encrypted data in `signature`. The flag survives the stream, the UI messages, the wire, and stored threads, and the next request sends the block back as `{ type: 'redacted_thinking', data }`.
+- On the AG-UI wire, a redacted block is its own reasoning message. Its id starts with `redacted_thinking-`, and the `REASONING_ENCRYPTED_VALUE` event's `entityId` points to that id. An AG-UI client keeps message ids, so it sends the block back as redacted data, not as a signature.
+- A thinking block's signature now names its reasoning message in `entityId`, not the step. An AG-UI client attaches the signature to that message, so it can send it back.
+- `ThinkingPart` and `ModelMessage['thinking']` have the new optional `redacted` field.
3 additions and 0 deletionsdocs/chat/thinking-content.mdModified
View file
@@ -28,11 +28,14 @@
content: string;
stepId?: string;
signature?: string;
+ redacted?: boolean;
```
​
The `ThinkingPart` appears in `UIMessage.parts` alongside `TextPart` and `ToolCallPart` entries. As reasoning tokens arrive, its `content` accumulates token by token.
​