-
-
Notifications
You must be signed in to change notification settings - Fork 352
fix(ai, ai-anthropic): send redacted thinking and tool errors back to Claude #1579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bbe7796
fix(ai, ai-anthropic): send redacted thinking and tool errors back to…
AlemTuzlak 529774b
refactor(ai): name the redacted thinking step set, note the signature…
tombeckenham c883b87
fix(ai, ai-anthropic): mark redacted thinking by its reasoning messag…
AlemTuzlak ee3c30f
Merge commit 'a5fce7f95b8b9c6eb57697aa1e3f587bf27483b9' into fix/anth…
AlemTuzlak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not store the
redacted_thinkingblob insignature.signatureis the signature of a normal thinking block's text. Thisdatavalue is a different field. There is no old client that already replays these blocks: the adapter used to drop them. Reusingsignaturedoes not keep a working replay.An old build of this library ignores
redactedand sends{ type: 'thinking', thinking: '', signature: <blob> }. That is the wrong block type. A separate field leavessignatureempty, so the existingif (!thinking.signature) continuecheck omits the part. Claude can still refuse that turn, but the request no longer contains a malformed thinking block.A client that stores the part unchanged and sends it back through this code works either way. A client that keeps only
contentloses the blob wherever it sits.Carry the bytes on something like
data(through the thinking part, the model message, and the wire), and send that field here asredacted_thinking.data. Leavesignaturefor real signatures. Update theThinkingPartnote inpackages/ai/src/types.tsthat currently sayssignatureholds this data.