Skip to content

@tanstack/ai-persistence@0.9.0

Choose a tag to compare

@github-actions github-actions released this 13 Oct 17:50
· 60 commits to main since this release
Immutable release. Only release title and notes can be modified.
293aea9

Minor Changes

  • #1715 fac0555 - New hooks for hosts that run chat() for a long session.
    • @tanstack/ai exports runAgentStream (runs a defineAgent agent outside a parent chat turn), createSubagentId, createSubagentSink, CapabilityRegistry, and the SubagentsBag and SubagentSink types. Pass the sink to keep interrupt objects and token usage. The finished event has interruptIds only.
    • MetadataStore has optional getVersioned and setIf for compare-and-set writes. The memory store of @tanstack/ai-persistence has both, and the conformance testkit checks them.
    • toolDefinition({ replay: 'safe' | 'never' }) tells a host if it can run the tool again after a crash.
    • The tool context has an optional detach field. A host sets it when it can move the call to the background. A tool passes its work to detach and races the two promises.
    • A tool that throws the MCP input-required shape can set the interrupt reason. The default is 'mcp_input'. The interrupt id stays mcp_input_<toolCallId>.

Patch Changes

  • #1697 cef1911 - A message store now keeps the mid-conversation change record of an assistant message when a client sends the same message again without it. With useChat, the prompt cache then holds across turns on models that get tool and prompt changes inside the conversation.

  • #1698 1bfcee3 - Keep a conversation valid when the next request goes to a different model.

    • Each assistant message records metadata.tanstack.source ({ provider, api, model }), and responseId and the resolved model when the provider sends them. A failed or aborted answer gets stopReason: 'error' or 'aborted'. RUN_FINISHED has a new responseId field. TextAdapter has new optional provider and api fields.
    • When the next request goes to a different source, the adapter removes signatures and redacted thinking, turns readable thinking into text, and rewrites tool call IDs to the shape the target API accepts. Each call stays paired with its result.
    • Every request drops failed and aborted assistant batches and adds a No result provided result for an unanswered tool call. The saved history does not change.
    • RUN_FINISHED and RUN_ERROR metadata now merge onto the assistant messages of that model call in StreamProcessor.
    • Anthropic: the new allowEmptySignature option (default false) replays unsigned thinking from the same source, for gateways. The new provider option names a gateway.
    • Azure OpenAI reports the azure-openai-responses API.
    • Gemini, Mistral, and Bedrock Converse send same-source thinking back to the model, in block order.
    • withPersistence writes the source and the stop reason onto streaming snapshot rows.
    • Adapter authors get transformMessagesForReplay() and hashToolCallId() from @tanstack/ai/adapter-internals.
  • Updated dependencies [1bfcee3, 412b0fe, a0150c2, b881627, fac0555, 6774e80, 5bd27f2, c20f7b0, cef1911, 51f72fb, 6f1e559, eb4eea0, cef1911, 7532b2b, 1bfcee3, 78edeb2, 44e3a0a, 7532b2b, 7a5c0d6, b881627]:

    • @tanstack/ai@0.69.0
    • @tanstack/ai-utils@0.4.2