refactor(ai): rename thinking `signature` to `encryptedValue` to match AG-UI #1581
Open
tombeckenham opened this issue ·0 comments
Task#
Rename the thinking field signature to encryptedValue, so the internal types use the same name as AG-UI. Keep reading signature from stored messages and from adapter events during a deprecation window.
Why#
signatureholds any provider's opaque reasoning artefact, not only a signature:- Anthropic thinking signature.
- Anthropic
redacted_thinkingdata (from #1579, withredacted: true). - OpenAI Responses
{ id, encrypted_content }as JSON (packages/openai-base/src/adapters/responses-text.ts).
- AG-UI calls this value
encryptedValue: onReasoningMessageand onREASONING_ENCRYPTED_VALUE. The wire codec already mapssignaturetoencryptedValue(packages/ai/src/utilities/ag-ui-wire.ts) and back (encryptedValueFrom()inpackages/ai/src/activities/chat/messages.ts). One value has two names, and the internal name is wrong for most of what it holds. ThinkingPart.signatureinpackages/ai/src/types.tshas a TODO that points here.
Why this was not done in #1579#
- It breaks user code that reads
part.signature, not only stored data. It needs a deprecated alias, so it is a minor, not a patch. - It touches about 60 sites:
aicore,ai-anthropic,openai-base,ai-byteplus, the persistence conformance kit, and the docs. STEP_FINISHED.signatureis part of the adapter contract. Third-party adapters emit it.
Scope#
- Add
encryptedValue?: stringtoThinkingPartandModelMessage['thinking']. Marksignature@deprecated. - Read shim: wherever stored or incoming messages become UI or model messages, read
encryptedValue ?? signature. Write onlyencryptedValue. - Adapter events: accept
STEP_FINISHED.encryptedValue, and keep readingSTEP_FINISHED.signature. Move first-party adapters (Anthropic, OpenAI base, BytePlus) to the new name. - Rename internal state, for example
thinkingStepSignaturesinpackages/ai/src/activities/chat/stream/types.ts. - Update the docs that name
signature(docs/chat/thinking-content.md,docs/migration/ag-ui-compliance.md,docs/adapters/byteplus.md) and add a migration note. - Changeset: minor for
@tanstack/aiand the adapters it touches.
Out of scope: removing signature. Do that in a later minor, after the window.
Version skew#
A server must read both names before any client writes only encryptedValue. A new client that sends only encryptedValue to an old server loses the bytes, and Claude can reject the next turn. Read both names in one release, then write only the new name.
Verification#
- A stored
UIMessagewith onlysignatureloads, and the next Anthropic request sends the same bytes back. Do this for a normal thinking block and for a redacted one. - A message with
encryptedValuegoes through the AG-UI wire and back without change. pnpm test:prpasses.
Related: #1579.
github-actions[bot](GitHub profile, opens in a new tab) assignedjherr
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
Sign in to join this conversation.