[Feature]: Say what kind of artefact `encryptedValue` holds, so redacted thinking can be replayed
Pre-flight Checklist
- I have searched existing issues and this hasn't been requested yet.
Problem or Motivation
encryptedValue does not say what kind of artefact it holds. A consumer that replays history to the provider cannot always rebuild the right block from it.
Anthropic has two block types with opaque bytes, and each one must go back with its own type:
| Block | Bytes | Text |
|---|---|---|
{ type: 'thinking', thinking, signature } |
signature |
Can be empty (display: 'omitted') |
{ type: 'redacted_thinking', data } |
data |
None |
Both arrive in AG-UI as the same shape:
{ role: 'reasoning', content: '', encryptedValue: '<opaque bytes>' }OpenAI Responses reasoning with no summary has the same shape too (encrypted_content).
The bytes are opaque, so a consumer cannot tell them apart. If it sends redacted data back as a thinking signature, or a signature back as redacted_thinking, Anthropic rejects the request.
The integrations in this repo already put both Anthropic kinds in the same slot:
- LangGraph (TS and Python):
resolveEncryptedReasoningContentreturnsredacted_thinking.dataas the encrypted value.aguiReasoningMessageToBlockrebuilds everyReasoningMessageas areasoningblock withencrypted_content. The kind of the bytes is gone. - CrewAI (
_reasoning.py):encryptedholds "any signature / redacted-thinking blobs".
ReasoningCapabilities.encrypted is set for the whole agent, so it does not help with one message.
Proposed Solution
Add an optional field that names the kind of the encrypted value, on ReasoningMessage and on REASONING_ENCRYPTED_VALUE:
type ReasoningMessage = {
// ...
encryptedValue?: string
/** What `encryptedValue` is, so a consumer can replay it as the right provider block. */
encryptedValueKind?: 'signature' | 'redacted'
}- Optional, so current producers and consumers keep working.
'redacted': the provider hid the reasoning.contentis empty, and the bytes are the whole block.'signature': the bytes verify or continue the visiblecontent.- Leave it out when the producer does not know.
The exact names are open. An open string, or a provider-scoped value such as 'anthropic.redacted_thinking', would also work.
Alternatives Considered
- Producer-specific metadata. TanStack AI uses
metadata.tanstack.redacted: truetoday (TanStack/ai#1579). It works between our own producer and consumer. A consumer that keepsencryptedValuebut dropsmetadataturns redacted bytes back into a signature, and other consumers cannot read our key. - Infer from empty
content. Does not work. Athinkingblock withdisplay: 'omitted'and OpenAI reasoning with no summary also have emptycontent. - Prefix or wrap the bytes. The value stops being the provider's value unchanged, and every consumer must know the private format.
Additional Context
- TanStack AI change that hit this: TanStack/ai#1579.
- Related: #2174 (Anthropic signature dropped on Bedrock), #2421 (reasoning messages in Claude adapter snapshots).
Source: ag-ui-protocol/ag-ui