Skip to content

@tanstack/ai-persistence@0.10.0

Choose a tag to compare

@github-actions github-actions released this 19 Oct 16:18
· 119 commits to main since this release
Immutable release. Only release title and notes can be modified.
7095ebb

Minor Changes

  • #1723 1d0f8f1 - Continue a child. With withPersistence on the parent chat(), an agent tool result gives the model the child's subagentRunId, and a later call of the same agent tool with sessionId continues that child from its stored transcript. With a host that sets subagents.binding.start, background: true starts the child and returns at once. These fields sit next to the agent's own fields, and each agent tool has them only when the run can use them. When the run uses sessionId or background, that name is reserved: chat() throws when an agent's inputSchema uses it. An agent without inputSchema takes the task as text in prompt, and the child gets it as the last user message. Agent tools also support the detach field of the tool context.

    The card keeps the checked input of an agent with inputSchema. On the client, part.subagent.input has it, typed from inputSchema when the agent declaration goes to useChat({ subagents }).

    @tanstack/ai adds LoadChildCapability, getLoadChild, and provideLoadChild, so a persistence middleware can load a stored child. A provider lists LoadChildCapability in provides. withPersistence in @tanstack/ai-persistence provides it: it stores the task of each child's first call and the thread that started it, and loads only the children of the calling thread.

Patch Changes

  • #1723 1d0f8f1 - A subagent can now return a plain value and call any activity.

    • defineAgent's run can return a promise of any value, such as an image result. The value arrives on SUBAGENT_FINISHED.result, and the parent model gets it as the tool result. A very long string inside an object result (for example a base64 image) reaches the parent model as a short note (compactForModel). A string result also streams as the child's text. The result of ctx.chat({ stream: false }) streams like the chat stream.
    • run gets the activities on ctx (ctx.chat, ctx.generateImage, ctx.generateVideo, and the rest), which fill in the thread id, a run id, and the abort signal. ctx.forward holds the fields for a plain chat() call. The optional produces field says what an agent makes.
    • A host can set subagents.binding (SubagentBinding) to add chat and generation middleware to every activity call of a child. A child's ctx.chat({ subagents }) passes it down to its own children.
    • Children inherit the prompt cache retention of the parent call.
    • The chat middleware context has subagentName and parentSubagentRunId. chat() takes both as options.
    • RunRecord gets optional fields for host sessions (kind, activity, agent, result, artifacts, principal, leaseOwner, leaseExpiresAt, checkpoint). The memory run stores keep them.
  • #1744 29bb0a4 - Store a tool result once when a run resumes from a client-tool interrupt. The client posts earlier tool results under interrupt snapshot ids the store never saw, so withPersistence appended a second copy and the next provider request failed.

  • #1786 30fa651 - Fix subagent limit and continue edges.

    • A background start that throws gives the maxCalls slot back. maxConcurrent counts that child until done settles. start now returns done.
    • A schema result that is not an object does not drop sessionId or background. A top-level anyOf schema still shows those fields.
    • A suspended child with no stored base keeps its transcript.
    • When the parent deadline is already past, the model gets subagent limit reached (no time left).
  • Updated dependencies [1d0f8f1, 1d0f8f1, 5f95dbd, 3170517, 3292bad, 3170517, 4298480, f68da51, 85c2956, 30fa651, 1d0f8f1, 3170517, 3170517]:

    • @tanstack/ai@0.70.0
    • @tanstack/ai-utils@0.5.0