Skip to content
Source
Sign inSign up
TanStack/ai

refactor(ai): rename thinking `signature` to `encryptedValue` to match AG-UI #1581

Opentombeckenham opened this issue 0 comments
tombeckenhamcommented

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

  • signature holds any provider's opaque reasoning artefact, not only a signature:
    • Anthropic thinking signature.
    • Anthropic redacted_thinking data (from #1579, with redacted: true).
    • OpenAI Responses { id, encrypted_content } as JSON (packages/openai-base/src/adapters/responses-text.ts).
  • AG-UI calls this value encryptedValue: on ReasoningMessage and on REASONING_ENCRYPTED_VALUE. The wire codec already maps signature to encryptedValue (packages/ai/src/utilities/ag-ui-wire.ts) and back (encryptedValueFrom() in packages/ai/src/activities/chat/messages.ts). One value has two names, and the internal name is wrong for most of what it holds.
  • ThinkingPart.signature in packages/ai/src/types.ts has 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: ai core, ai-anthropic, openai-base, ai-byteplus, the persistence conformance kit, and the docs.
  • STEP_FINISHED.signature is part of the adapter contract. Third-party adapters emit it.

Scope

  1. Add encryptedValue?: string to ThinkingPart and ModelMessage['thinking']. Mark signature @deprecated.
  2. Read shim: wherever stored or incoming messages become UI or model messages, read encryptedValue ?? signature. Write only encryptedValue.
  3. Adapter events: accept STEP_FINISHED.encryptedValue, and keep reading STEP_FINISHED.signature. Move first-party adapters (Anthropic, OpenAI base, BytePlus) to the new name.
  4. Rename internal state, for example thinkingStepSignatures in packages/ai/src/activities/chat/stream/types.ts.
  5. 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.
  6. Changeset: minor for @tanstack/ai and 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 UIMessage with only signature loads, 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 encryptedValue goes through the AG-UI wire and back without change.
  • pnpm test:pr passes.

Related: #1579.

Sign in to join this conversation.