Repository navigation
@tanstack/ai-persistence@0.10.0
Minor Changes
-
#1723
1d0f8f1- Continue a child. WithwithPersistenceon the parentchat(), an agent tool result gives the model the child'ssubagentRunId, and a later call of the same agent tool withsessionIdcontinues that child from its stored transcript. With a host that setssubagents.binding.start,background: truestarts 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 usessessionIdorbackground, that name is reserved:chat()throws when an agent'sinputSchemauses it. An agent withoutinputSchematakes the task as text inprompt, and the child gets it as the last user message. Agent tools also support thedetachfield of the tool context.The card keeps the checked input of an agent with
inputSchema. On the client,part.subagent.inputhas it, typed frominputSchemawhen the agent declaration goes touseChat({ subagents }).@tanstack/aiaddsLoadChildCapability,getLoadChild, andprovideLoadChild, so a persistence middleware can load a stored child. A provider listsLoadChildCapabilityinprovides.withPersistencein@tanstack/ai-persistenceprovides 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'sruncan return a promise of any value, such as an image result. The value arrives onSUBAGENT_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 ofctx.chat({ stream: false })streams like the chat stream.rungets the activities onctx(ctx.chat,ctx.generateImage,ctx.generateVideo, and the rest), which fill in the thread id, a run id, and the abort signal.ctx.forwardholds the fields for a plainchat()call. The optionalproducesfield 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'sctx.chat({ subagents })passes it down to its own children. - Children inherit the prompt cache retention of the parent call.
- The chat middleware context has
subagentNameandparentSubagentRunId.chat()takes both as options. RunRecordgets 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, sowithPersistenceappended a second copy and the next provider request failed. -
#1786
30fa651- Fix subagent limit and continue edges.- A background
startthat throws gives themaxCallsslot back.maxConcurrentcounts that child untildonesettles.startnow returnsdone. - A schema result that is not an object does not drop
sessionIdorbackground. A top-levelanyOfschema still shows those fields. - A suspended child with no stored
basekeeps its transcript. - When the parent deadline is already past, the model gets
subagent limit reached (no time left).
- A background
-
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