From a007ccd92e3500b9209642624a189cd5cfa3e0fe Mon Sep 17 00:00:00 2001 From: Upstash Box Date: Sun, 27 Sep 2026 15:20:38 +0000 Subject: [PATCH 01/15] docs(redis): add AgentKit TanStack AI page (DX-3081) Documents @upstash/agentkit-tanstack-ai: persistence, resumable streams, distributed locks, long-term memory, tool cache / rate limit middlewares and search tools. Added to both AgentKit nav groups. --- docs.json | 6 +- redis/sdks/agentkit/tanstack-ai.mdx | 189 ++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 redis/sdks/agentkit/tanstack-ai.mdx diff --git a/docs.json b/docs.json index 461b5f102..9bfb799a5 100644 --- a/docs.json +++ b/docs.json @@ -747,7 +747,8 @@ "group": "AgentKit", "pages": [ "redis/sdks/agentkit/ai-sdk", - "redis/sdks/agentkit/eve" + "redis/sdks/agentkit/eve", + "redis/sdks/agentkit/tanstack-ai" ] }, "redis/sdks/mcp", @@ -892,7 +893,8 @@ "group": "AgentKit", "pages": [ "redis/sdks/agentkit/ai-sdk", - "redis/sdks/agentkit/eve" + "redis/sdks/agentkit/eve", + "redis/sdks/agentkit/tanstack-ai" ] } ] diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx new file mode 100644 index 000000000..35270fea5 --- /dev/null +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -0,0 +1,189 @@ +--- +title: "TanStack AI Persistence, Resumable Streams & Memory with Redis" +sidebarTitle: "TanStack AI" +description: "Production backends for TanStack AI on Upstash Redis — chat persistence, resumable streams, distributed locks, long-term memory, tool caching, rate limiting, and RAG tools." +--- + +[TanStack AI](https://tanstack.com/ai) defines the contracts for an agent's production state — chat +persistence, resumable streaming, locks, memory — and ships in-memory implementations that only work +inside one process. `@upstash/agentkit-tanstack-ai` implements them on Upstash Redis, so they hold +across serverless instances, page reloads, and devices. + +| Import | Plugs into | Feature | +| --- | --- | --- | +| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | +| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/redis/search/introduction). | +| `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | +| `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | + +`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. + +```bash +npm install @upstash/agentkit-tanstack-ai @tanstack/ai +# for the features you use: +npm install @tanstack/ai-persistence @tanstack/ai-memory +``` + + + Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by + default. Pass your own `@upstash/redis` client as `redis` to override. + + +## How to persist TanStack AI chats in Redis + +```ts +import { chat } from "@tanstack/ai"; +import { withPersistence } from "@tanstack/ai-persistence"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; + +const persistence = upstashPersistence(); + +chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); +``` + +This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one +Lua script, so concurrent instances cannot interleave it. + + + ```ts + upstashPersistence({ + redis, // optional: defaults to Redis.fromEnv() + prefix: "agentkit:tanstack", // optional: base key prefix + messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + }); + ``` + + The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another + backend with `composePersistence` if you need them. + + +## How to resume a TanStack AI stream after a reload + +```ts +import { chat, toServerSentEventsResponse } from "@tanstack/ai"; +import { upstashStream } from "@upstash/agentkit-tanstack-ai"; + +export async function POST(request: Request) { + const stream = chat({ adapter, messages, threadId }); + return toServerSentEventsResponse(stream, { durability: { adapter: upstashStream(request) } }); +} +``` + +Every chunk is written to a Redis Stream before it is sent. A client that reconnects with +`Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever +instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. + + + ```ts + upstashStream(request, { + ttlSeconds: 86_400, // optional: how long a run stays resumable + pollIntervalMs: 150, // optional: how often a caught-up reader checks for new chunks + firstChunkDeadlineMs: 2_000, // optional: how long a join waits for a run that has not started + }); + ``` + + +## How to lock a TanStack AI thread across instances + +```ts +import { withLocks } from "@tanstack/ai/locks"; +import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; + +chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); +``` + +A lease that is renewed while the critical section runs. If the lease is lost, the section's +`signal` aborts. + + + ```ts + upstashLocks({ + leaseMs: 30_000, // optional: lease lifetime without renewal + acquireTimeoutMs: 30_000, // optional: how long to wait for a held key + retryDelayMs: 100, // optional: delay between attempts + }); + ``` + + +## How to add long-term memory to TanStack AI + +```ts +import { memoryMiddleware } from "@tanstack/ai-memory"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + middleware: [ + memoryMiddleware({ + adapter: upstashMemory(), + // derive these server-side from the session, never from the request body + scope: (ctx) => ({ threadId: ctx.threadId, userId: session.userId }), + }), + ], +}); +``` + +Before each turn, the most relevant memories for the user's message are added to the system prompt, +labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each +turn's user message is captured too. Memory is per user across threads by default. + + + ```ts + upstashMemory({ + topK: 5, // optional: memories injected per turn + scopeBy: "user", // optional: "user" (across threads) or "thread" + captureUserMessages: true, // optional: store each turn's user message + saveTool: true, // optional: offer the save_memory tool + waitForIndexing: true, // optional: make a save recallable on the very next turn + }); + ``` + + +## How to cache tools and rate limit with TanStack AI + +```ts +import { rateLimit, Ratelimit, toolCache } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + tools: [getWeather, sendEmail], + middleware: [ + rateLimit({ limiter: Ratelimit.slidingWindow(10, "60 s"), identifier: userId }), + toolCache({ tools: ["get_weather"], userId, ttlSeconds: 600 }), + ], +}); +``` + +`toolCache` only caches the tools you list — list deterministic, side-effect-free tools only. +`rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 +instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. + +## How to add RAG with TanStack AI + +```ts +import { s } from "@upstash/redis"; +import { createSearchTools } from "@upstash/agentkit-tanstack-ai"; + +const tools = createSearchTools({ + indexName: "products", + schema: s.object({ name: s.string(), price: s.number(), category: s.string().noTokenize() }), +}); + +chat({ adapter, messages, tools }); +``` + +The tool descriptions are generated from the schema, and the index is created on first use. + + + + Source and README for the package. + + + The framework these backends plug into. + + From 76088c4e0b953767976fcb144a87a6b8e8521cfa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:21:36 +0000 Subject: [PATCH 02/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++ llms.txt | 2 + 2 files changed, 376 insertions(+) diff --git a/llms-full.txt b/llms-full.txt index b55493f88..78cddb710 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86320,6 +86320,380 @@ Two complete `eve` apps live in the AgentKit repo: +# TanStack AI Persistence, Resumable Streams & Memory with Redis +Source: https://upstash.com/docs/redis/sdks/agentkit/tanstack-ai + +[TanStack AI](https://tanstack.com/ai) defines the contracts for an agent's production state — chat +persistence, resumable streaming, locks, memory — and ships in-memory implementations that only work +inside one process. `@upstash/agentkit-tanstack-ai` implements them on Upstash Redis, so they hold +across serverless instances, page reloads, and devices. + +| Import | Plugs into | Feature | +| --- | --- | --- | +| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | +| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | +| `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | +| `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | + +`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. + +```bash +npm install @upstash/agentkit-tanstack-ai @tanstack/ai +# for the features you use: +npm install @tanstack/ai-persistence @tanstack/ai-memory +``` + + + Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by + default. Pass your own `@upstash/redis` client as `redis` to override. + + +## How to persist TanStack AI chats in Redis + +```ts +import { chat } from "@tanstack/ai"; +import { withPersistence } from "@tanstack/ai-persistence"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; + +const persistence = upstashPersistence(); + +chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); +``` + +This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one +Lua script, so concurrent instances cannot interleave it. + + + ```ts + upstashPersistence({ + redis, // optional: defaults to Redis.fromEnv() + prefix: "agentkit:tanstack", // optional: base key prefix + messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + }); + ``` + + The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another + backend with `composePersistence` if you need them. + + +## How to resume a TanStack AI stream after a reload + +```ts +import { chat, toServerSentEventsResponse } from "@tanstack/ai"; +import { upstashStream } from "@upstash/agentkit-tanstack-ai"; + +export async function POST(request: Request) { + const stream = chat({ adapter, messages, threadId }); + return toServerSentEventsResponse(stream, { durability: { adapter: upstashStream(request) } }); +} +``` + +Every chunk is written to a Redis Stream before it is sent. A client that reconnects with +`Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever +instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. + + + ```ts + upstashStream(request, { + ttlSeconds: 86_400, // optional: how long a run stays resumable + pollIntervalMs: 150, // optional: how often a caught-up reader checks for new chunks + firstChunkDeadlineMs: 2_000, // optional: how long a join waits for a run that has not started + }); + ``` + + +## How to lock a TanStack AI thread across instances + +```ts +import { withLocks } from "@tanstack/ai/locks"; +import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; + +chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); +``` + +A lease that is renewed while the critical section runs. If the lease is lost, the section's +`signal` aborts. + + + ```ts + upstashLocks({ + leaseMs: 30_000, // optional: lease lifetime without renewal + acquireTimeoutMs: 30_000, // optional: how long to wait for a held key + retryDelayMs: 100, // optional: delay between attempts + }); + ``` + + +## How to add long-term memory to TanStack AI + +```ts +import { memoryMiddleware } from "@tanstack/ai-memory"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + middleware: [ + memoryMiddleware({ + adapter: upstashMemory(), + // derive these server-side from the session, never from the request body + scope: (ctx) => ({ threadId: ctx.threadId, userId: session.userId }), + }), + ], +}); +``` + +Before each turn, the most relevant memories for the user's message are added to the system prompt, +labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each +turn's user message is captured too. Memory is per user across threads by default. + + + ```ts + upstashMemory({ + topK: 5, // optional: memories injected per turn + scopeBy: "user", // optional: "user" (across threads) or "thread" + captureUserMessages: true, // optional: store each turn's user message + saveTool: true, // optional: offer the save_memory tool + waitForIndexing: true, // optional: make a save recallable on the very next turn + }); + ``` + + +## How to cache tools and rate limit with TanStack AI + +```ts +import { rateLimit, Ratelimit, toolCache } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + tools: [getWeather, sendEmail], + middleware: [ + rateLimit({ limiter: Ratelimit.slidingWindow(10, "60 s"), identifier: userId }), + toolCache({ tools: ["get_weather"], userId, ttlSeconds: 600 }), + ], +}); +``` + +`toolCache` only caches the tools you list — list deterministic, side-effect-free tools only. +`rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 +instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. + +## How to add RAG with TanStack AI + +```ts +import { s } from "@upstash/redis"; +import { createSearchTools } from "@upstash/agentkit-tanstack-ai"; + +const tools = createSearchTools({ + indexName: "products", + schema: s.object({ name: s.string(), price: s.number(), category: s.string().noTokenize() }), +}); + +chat({ adapter, messages, tools }); +``` + +The tool descriptions are generated from the schema, and the index is created on first use. + + + + Source and README for the package. + + + The framework these backends plug into. + + + +# TanStack AI Persistence, Resumable Streams & Memory with Redis +Source: https://upstash.com/docs/redis/sdks/agentkit/tanstack-ai + +[TanStack AI](https://tanstack.com/ai) defines the contracts for an agent's production state — chat +persistence, resumable streaming, locks, memory — and ships in-memory implementations that only work +inside one process. `@upstash/agentkit-tanstack-ai` implements them on Upstash Redis, so they hold +across serverless instances, page reloads, and devices. + +| Import | Plugs into | Feature | +| --- | --- | --- | +| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | +| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | +| `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | +| `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | + +`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. + +```bash +npm install @upstash/agentkit-tanstack-ai @tanstack/ai +# for the features you use: +npm install @tanstack/ai-persistence @tanstack/ai-memory +``` + + + Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by + default. Pass your own `@upstash/redis` client as `redis` to override. + + +## How to persist TanStack AI chats in Redis + +```ts +import { chat } from "@tanstack/ai"; +import { withPersistence } from "@tanstack/ai-persistence"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; + +const persistence = upstashPersistence(); + +chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); +``` + +This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one +Lua script, so concurrent instances cannot interleave it. + + + ```ts + upstashPersistence({ + redis, // optional: defaults to Redis.fromEnv() + prefix: "agentkit:tanstack", // optional: base key prefix + messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + }); + ``` + + The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another + backend with `composePersistence` if you need them. + + +## How to resume a TanStack AI stream after a reload + +```ts +import { chat, toServerSentEventsResponse } from "@tanstack/ai"; +import { upstashStream } from "@upstash/agentkit-tanstack-ai"; + +export async function POST(request: Request) { + const stream = chat({ adapter, messages, threadId }); + return toServerSentEventsResponse(stream, { durability: { adapter: upstashStream(request) } }); +} +``` + +Every chunk is written to a Redis Stream before it is sent. A client that reconnects with +`Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever +instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. + + + ```ts + upstashStream(request, { + ttlSeconds: 86_400, // optional: how long a run stays resumable + pollIntervalMs: 150, // optional: how often a caught-up reader checks for new chunks + firstChunkDeadlineMs: 2_000, // optional: how long a join waits for a run that has not started + }); + ``` + + +## How to lock a TanStack AI thread across instances + +```ts +import { withLocks } from "@tanstack/ai/locks"; +import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; + +chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); +``` + +A lease that is renewed while the critical section runs. If the lease is lost, the section's +`signal` aborts. + + + ```ts + upstashLocks({ + leaseMs: 30_000, // optional: lease lifetime without renewal + acquireTimeoutMs: 30_000, // optional: how long to wait for a held key + retryDelayMs: 100, // optional: delay between attempts + }); + ``` + + +## How to add long-term memory to TanStack AI + +```ts +import { memoryMiddleware } from "@tanstack/ai-memory"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + middleware: [ + memoryMiddleware({ + adapter: upstashMemory(), + // derive these server-side from the session, never from the request body + scope: (ctx) => ({ threadId: ctx.threadId, userId: session.userId }), + }), + ], +}); +``` + +Before each turn, the most relevant memories for the user's message are added to the system prompt, +labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each +turn's user message is captured too. Memory is per user across threads by default. + + + ```ts + upstashMemory({ + topK: 5, // optional: memories injected per turn + scopeBy: "user", // optional: "user" (across threads) or "thread" + captureUserMessages: true, // optional: store each turn's user message + saveTool: true, // optional: offer the save_memory tool + waitForIndexing: true, // optional: make a save recallable on the very next turn + }); + ``` + + +## How to cache tools and rate limit with TanStack AI + +```ts +import { rateLimit, Ratelimit, toolCache } from "@upstash/agentkit-tanstack-ai"; + +chat({ + adapter, + messages, + tools: [getWeather, sendEmail], + middleware: [ + rateLimit({ limiter: Ratelimit.slidingWindow(10, "60 s"), identifier: userId }), + toolCache({ tools: ["get_weather"], userId, ttlSeconds: 600 }), + ], +}); +``` + +`toolCache` only caches the tools you list — list deterministic, side-effect-free tools only. +`rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 +instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. + +## How to add RAG with TanStack AI + +```ts +import { s } from "@upstash/redis"; +import { createSearchTools } from "@upstash/agentkit-tanstack-ai"; + +const tools = createSearchTools({ + indexName: "products", + schema: s.object({ name: s.string(), price: s.number(), category: s.string().noTokenize() }), +}); + +chat({ adapter, messages, tools }); +``` + +The tool descriptions are generated from the schema, and the index is created on first use. + + + + Source and README for the package. + + + The framework these backends plug into. + + + # Upstash Redis MCP Source: https://upstash.com/docs/redis/sdks/mcp diff --git a/llms.txt b/llms.txt index aad352832..e5bf8ec35 100644 --- a/llms.txt +++ b/llms.txt @@ -731,6 +731,8 @@ - [Vercel AI SDK Memory, RAG & Chat History with Redis](https://upstash.com/docs/redis/sdks/agentkit/ai-sdk.md): Add long-term memory, RAG, and chat history to the Vercel AI SDK with Upstash Redis — drop-in tools for generateText and streamText, no separate vector database. - [Memory, Chat History, RAG, Rate Limiting & Sandboxes for the Vercel Eve Agent Framework](https://upstash.com/docs/redis/sdks/agentkit/eve.md): Add long-term memory, searchable chat history, RAG, rate limiting, tool caching, and sandboxes to Vercel's Eve agent framework with Upstash Redis — no separate vector database. - [Memory, Chat History, RAG, Rate Limiting & Sandboxes for the Vercel Eve Agent Framework](https://upstash.com/docs/redis/sdks/agentkit/eve.md): Add long-term memory, searchable chat history, RAG, rate limiting, tool caching, and sandboxes to Vercel's Eve agent framework with Upstash Redis — no separate vector database. +- [TanStack AI Persistence, Resumable Streams & Memory with Redis](https://upstash.com/docs/redis/sdks/agentkit/tanstack-ai.md): Production backends for TanStack AI on Upstash Redis — chat persistence, resumable streams, distributed locks, long-term memory, tool caching, rate limiting, and RAG tools. +- [TanStack AI Persistence, Resumable Streams & Memory with Redis](https://upstash.com/docs/redis/sdks/agentkit/tanstack-ai.md): Production backends for TanStack AI on Upstash Redis — chat persistence, resumable streams, distributed locks, long-term memory, tool caching, rate limiting, and RAG tools. - [Upstash Redis MCP](https://upstash.com/docs/redis/sdks/mcp.md) - [ARCOUNT](https://upstash.com/docs/redis/sdks/py/commands/array/arcount.md): Count the occupied slots in an array. - [ARDEL](https://upstash.com/docs/redis/sdks/py/commands/array/ardel.md): Delete array values without shifting later indexes. From 0e07ab2663d6ee9387a2429d431e269b6ee2414a Mon Sep 17 00:00:00 2001 From: Cahid Arda Oz Date: Sun, 27 Sep 2026 15:48:56 +0000 Subject: [PATCH 03/15] docs(redis): cover generation runs, artifacts and Blob-backed blobs (DX-3081) --- redis/sdks/agentkit/tanstack-ai.mdx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index 35270fea5..1cf27b0a3 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -11,7 +11,7 @@ across serverless instances, page reloads, and devices. | Import | Plugs into | Feature | | --- | --- | --- | -| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | | `upstashLocks` | `withLocks()` | One writer per thread across instances. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/redis/search/introduction). | @@ -43,7 +43,17 @@ const persistence = upstashPersistence(); chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); ``` -This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +This covers every TanStack AI persistence store: `messages`, `runs`, `interrupts`, and `metadata` for +chats, plus `generationRuns` and `artifacts` for one-shot generation jobs such as images or speech. The +`blobs` store for generated bytes is added when you pass an Upstash Blob bucket: + +```ts +import { Bucket } from "@upstash/blob"; + +const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); +``` + + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -53,11 +63,12 @@ Lua script, so concurrent instances cannot interleave it. redis, // optional: defaults to Redis.fromEnv() prefix: "agentkit:tanstack", // optional: base key prefix messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + bucket: Bucket.fromEnv(), // optional: Upstash Blob bucket for generated files }); ``` - The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another - backend with `composePersistence` if you need them. + Pass `bucket` to also store the bytes of generated files (images, audio, video) in + [Upstash Blob](/blob/overall/quickstart). Without it, there is no `blobs` store. ## How to resume a TanStack AI stream after a reload From 972f521a51f4f9ac3ebde22445e4cad87aba38f6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:49:35 +0000 Subject: [PATCH 04/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 78cddb710..e1b6d2cc2 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86330,7 +86330,7 @@ across serverless instances, page reloads, and devices. | Import | Plugs into | Feature | | --- | --- | --- | -| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | | `upstashLocks` | `withLocks()` | One writer per thread across instances. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | @@ -86362,7 +86362,17 @@ const persistence = upstashPersistence(); chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); ``` -This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +This covers every TanStack AI persistence store: `messages`, `runs`, `interrupts`, and `metadata` for +chats, plus `generationRuns` and `artifacts` for one-shot generation jobs such as images or speech. The +`blobs` store for generated bytes is added when you pass an Upstash Blob bucket: + +```ts +import { Bucket } from "@upstash/blob"; + +const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); +``` + + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86372,11 +86382,12 @@ Lua script, so concurrent instances cannot interleave it. redis, // optional: defaults to Redis.fromEnv() prefix: "agentkit:tanstack", // optional: base key prefix messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + bucket: Bucket.fromEnv(), // optional: Upstash Blob bucket for generated files }); ``` - The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another - backend with `composePersistence` if you need them. + Pass `bucket` to also store the bytes of generated files (images, audio, video) in + [Upstash Blob](/docs/blob/overall/quickstart). Without it, there is no `blobs` store. ## How to resume a TanStack AI stream after a reload @@ -86517,7 +86528,7 @@ across serverless instances, page reloads, and devices. | Import | Plugs into | Feature | | --- | --- | --- | -| `upstashPersistence` | `withPersistence()` | Transcripts, runs, human-in-the-loop interrupts, and metadata that survive restarts. | +| `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | | `upstashLocks` | `withLocks()` | One writer per thread across instances. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | @@ -86549,7 +86560,17 @@ const persistence = upstashPersistence(); chat({ adapter, messages, threadId, middleware: [withPersistence(persistence)] }); ``` -This stores the `messages`, `runs`, `interrupts`, and `metadata` stores. Runs are indexed by thread, so +This covers every TanStack AI persistence store: `messages`, `runs`, `interrupts`, and `metadata` for +chats, plus `generationRuns` and `artifacts` for one-shot generation jobs such as images or speech. The +`blobs` store for generated bytes is added when you pass an Upstash Blob bucket: + +```ts +import { Bucket } from "@upstash/blob"; + +const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); +``` + + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86559,11 +86580,12 @@ Lua script, so concurrent instances cannot interleave it. redis, // optional: defaults to Redis.fromEnv() prefix: "agentkit:tanstack", // optional: base key prefix messagesTtlSeconds: 60 * 60 * 24 * 30, // optional: expire idle transcripts (default: never) + bucket: Bucket.fromEnv(), // optional: Upstash Blob bucket for generated files }); ``` - The `generationRuns`, `artifacts`, and `blobs` stores are not provided yet. Add them from another - backend with `composePersistence` if you need them. + Pass `bucket` to also store the bytes of generated files (images, audio, video) in + [Upstash Blob](/docs/blob/overall/quickstart). Without it, there is no `blobs` store. ## How to resume a TanStack AI stream after a reload From fbbfc2dfcefba4604b2a032c4c708dd1624971cd Mon Sep 17 00:00:00 2001 From: Cahid Arda Oz Date: Sun, 27 Sep 2026 16:07:17 +0000 Subject: [PATCH 05/15] docs(redis): list the environment variables each AgentKit TanStack AI utility reads (DX-3081) --- redis/sdks/agentkit/tanstack-ai.mdx | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index 1cf27b0a3..39712d3ec 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -26,10 +26,30 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` - - Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by - default. Pass your own `@upstash/redis` client as `redis` to override. - +## Environment variables + +| Utility | Environment variables it reads | +| --- | --- | +| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | +| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | +| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | + +The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` +and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. + +```bash .env +UPSTASH_REDIS_REST_URL=https://your-db.upstash.io +UPSTASH_REDIS_REST_TOKEN=your-token +# only if you store generated files in Upstash Blob +UPSTASH_BLOB_TOKEN=your-blob-token +``` ## How to persist TanStack AI chats in Redis From 162291673c1ef6a3434abf3cd36c983ab3c17047 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 16:07:41 +0000 Subject: [PATCH 06/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 56 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index e1b6d2cc2..846f033ec 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86345,10 +86345,30 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` - - Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by - default. Pass your own `@upstash/redis` client as `redis` to override. - +## Environment variables + +| Utility | Environment variables it reads | +| --- | --- | +| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | +| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | +| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | + +The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` +and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. + +```bash .env +UPSTASH_REDIS_REST_URL=https://your-db.upstash.io +UPSTASH_REDIS_REST_TOKEN=your-token +# only if you store generated files in Upstash Blob +UPSTASH_BLOB_TOKEN=your-blob-token +``` ## How to persist TanStack AI chats in Redis @@ -86543,10 +86563,30 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` - - Every helper reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by - default. Pass your own `@upstash/redis` client as `redis` to override. - +## Environment variables + +| Utility | Environment variables it reads | +| --- | --- | +| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | +| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | +| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | +| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | + +The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` +and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. + +```bash .env +UPSTASH_REDIS_REST_URL=https://your-db.upstash.io +UPSTASH_REDIS_REST_TOKEN=your-token +# only if you store generated files in Upstash Blob +UPSTASH_BLOB_TOKEN=your-blob-token +``` ## How to persist TanStack AI chats in Redis From 00f64d421cfe1397d7cfad0f5f4a84ce39633ce1 Mon Sep 17 00:00:00 2001 From: Cahid Arda Oz Date: Sun, 27 Sep 2026 16:07:46 +0000 Subject: [PATCH 07/15] docs(redis): move environment variables into each section (DX-3081) --- redis/sdks/agentkit/tanstack-ai.mdx | 42 +++++++++++++---------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index 39712d3ec..bf2a5d306 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -26,30 +26,11 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -## Environment variables - -| Utility | Environment variables it reads | -| --- | --- | -| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | -| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | -| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | - -The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` -and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. - -```bash .env -UPSTASH_REDIS_REST_URL=https://your-db.upstash.io -UPSTASH_REDIS_REST_TOKEN=your-token -# only if you store generated files in Upstash Blob -UPSTASH_BLOB_TOKEN=your-blob-token -``` + + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't + pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set + `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + ## How to persist TanStack AI chats in Redis @@ -73,6 +54,9 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads +`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -107,6 +91,8 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashStream(request, { @@ -129,6 +115,8 @@ chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sa A lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashLocks({ @@ -162,6 +150,8 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashMemory({ @@ -194,6 +184,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ## How to add RAG with TanStack AI ```ts @@ -210,6 +202,8 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + Source and README for the package. From a75ee208c9be4e7c2a19d067e73311b3027b82a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 16:08:07 +0000 Subject: [PATCH 08/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 84 ++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 846f033ec..93e44a58f 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86345,30 +86345,11 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -## Environment variables - -| Utility | Environment variables it reads | -| --- | --- | -| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | -| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | -| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | - -The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` -and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. - -```bash .env -UPSTASH_REDIS_REST_URL=https://your-db.upstash.io -UPSTASH_REDIS_REST_TOKEN=your-token -# only if you store generated files in Upstash Blob -UPSTASH_BLOB_TOKEN=your-blob-token -``` + + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't + pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set + `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + ## How to persist TanStack AI chats in Redis @@ -86392,6 +86373,9 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads +`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86426,6 +86410,8 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashStream(request, { @@ -86448,6 +86434,8 @@ chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sa A lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashLocks({ @@ -86481,6 +86469,8 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashMemory({ @@ -86513,6 +86503,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ## How to add RAG with TanStack AI ```ts @@ -86529,6 +86521,8 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + Source and README for the package. @@ -86563,30 +86557,11 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -## Environment variables - -| Utility | Environment variables it reads | -| --- | --- | -| `upstashPersistence` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashPersistence({ bucket })` blobs | The Redis variables above, plus `UPSTASH_BLOB_TOKEN` when the bucket is `Bucket.fromEnv()` | -| `upstashStream` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashLocks` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashMemory` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `toolCache` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `rateLimit`, `createRateLimit` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `createSearchTools` | `UPSTASH_REDIS_REST_URL`, `UPSTASH_REDIS_REST_TOKEN` | -| `upstashBlobStore` | None. You pass both the `redis` client and the `bucket` | -| All of the above | `UPSTASH_DISABLE_TELEMETRY` (optional): set it to turn off the SDK version header | - -The Redis variables are read only when you don't pass a `redis` client. In Node.js, `KV_REST_API_URL` -and `KV_REST_API_TOKEN` also work as a fallback, as with `Redis.fromEnv()`. - -```bash .env -UPSTASH_REDIS_REST_URL=https://your-db.upstash.io -UPSTASH_REDIS_REST_TOKEN=your-token -# only if you store generated files in Upstash Blob -UPSTASH_BLOB_TOKEN=your-blob-token -``` + + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't + pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set + `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + ## How to persist TanStack AI chats in Redis @@ -86610,6 +86585,9 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads +`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. + Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86644,6 +86622,8 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashStream(request, { @@ -86666,6 +86646,8 @@ chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sa A lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashLocks({ @@ -86699,6 +86681,8 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ```ts upstashMemory({ @@ -86731,6 +86715,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + ## How to add RAG with TanStack AI ```ts @@ -86747,6 +86733,8 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. + Source and README for the package. From 550682b30dbf83e725ca1e5b770e6563af6c5759 Mon Sep 17 00:00:00 2001 From: Cahid Arda Oz Date: Sun, 27 Sep 2026 16:16:18 +0000 Subject: [PATCH 09/15] docs(redis): drop KV_REST_API_* mention (DX-3081) --- redis/sdks/agentkit/tanstack-ai.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index bf2a5d306..a3438478f 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -28,8 +28,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set - `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. ## How to persist TanStack AI chats in Redis From ce3bf2300eea1196401bb7185e853912bc671816 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 16:16:43 +0000 Subject: [PATCH 10/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 93e44a58f..5018ac9a4 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86347,8 +86347,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set - `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. ## How to persist TanStack AI chats in Redis @@ -86559,8 +86558,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client (`KV_REST_API_URL` / `KV_REST_API_TOKEN` also work in Node.js). Set - `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. ## How to persist TanStack AI chats in Redis From 90ca2b1f627e1a7f4e3744c552a53001bde8f360 Mon Sep 17 00:00:00 2001 From: Cahid Arda Oz Date: Mon, 28 Sep 2026 14:39:52 +0000 Subject: [PATCH 11/15] AgentKit TanStack AI: subpath imports for persistence and memory; correct what withLocks does (DX-3081) --- redis/sdks/agentkit/tanstack-ai.mdx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index a3438478f..9e86125d3 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -13,7 +13,7 @@ across serverless instances, page reloads, and devices. | --- | --- | --- | | `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | -| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashLocks` | `withLocks()` | Distributed locks for TanStack AI middleware, such as its sandbox setup. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/redis/search/introduction). | | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | @@ -26,6 +26,9 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` +Persistence and memory are imported from their own entry points, +`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. @@ -36,7 +39,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; -import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai/persistence"; const persistence = upstashPersistence(); @@ -102,7 +105,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ``` -## How to lock a TanStack AI thread across instances +## How to use distributed locks with TanStack AI ```ts import { withLocks } from "@tanstack/ai/locks"; @@ -111,8 +114,14 @@ import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); ``` -A lease that is renewed while the critical section runs. If the lease is lost, the section's -`signal` aborts. +`withLocks` doesn't lock anything by itself. It gives the lock store to later middleware, which lock +the one step they must not run twice: `withSandbox` uses it so two concurrent requests for a thread +don't both create a sandbox, and your own middleware can use it through `getLocks(ctx)`. It does not +serialize whole chat turns. Unlike TanStack's `InMemoryLockStore`, which only works inside one +process, `upstashLocks()` coordinates across instances. + +Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the +section's `signal` aborts. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. @@ -130,7 +139,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; -import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; chat({ adapter, From f80f4cfa9a0175e89df804029ba1e7fc3f576823 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2026 14:40:25 +0000 Subject: [PATCH 12/15] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 5018ac9a4..a2c8be170 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86332,7 +86332,7 @@ across serverless instances, page reloads, and devices. | --- | --- | --- | | `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | -| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashLocks` | `withLocks()` | Distributed locks for TanStack AI middleware, such as its sandbox setup. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | @@ -86345,6 +86345,9 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` +Persistence and memory are imported from their own entry points, +`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. @@ -86355,7 +86358,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; -import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai/persistence"; const persistence = upstashPersistence(); @@ -86421,7 +86424,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ``` -## How to lock a TanStack AI thread across instances +## How to use distributed locks with TanStack AI ```ts import { withLocks } from "@tanstack/ai/locks"; @@ -86430,8 +86433,14 @@ import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); ``` -A lease that is renewed while the critical section runs. If the lease is lost, the section's -`signal` aborts. +`withLocks` doesn't lock anything by itself. It gives the lock store to later middleware, which lock +the one step they must not run twice: `withSandbox` uses it so two concurrent requests for a thread +don't both create a sandbox, and your own middleware can use it through `getLocks(ctx)`. It does not +serialize whole chat turns. Unlike TanStack's `InMemoryLockStore`, which only works inside one +process, `upstashLocks()` coordinates across instances. + +Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the +section's `signal` aborts. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. @@ -86449,7 +86458,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; -import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; chat({ adapter, @@ -86543,7 +86552,7 @@ across serverless instances, page reloads, and devices. | --- | --- | --- | | `upstashPersistence` | `withPersistence()`, `withGenerationPersistence()` | Transcripts, runs, human-in-the-loop interrupts, metadata, generation jobs, and generated files. | | `upstashStream` | `durability` on the response | Resume a stream after a reload, or open the same thread on another device. | -| `upstashLocks` | `withLocks()` | One writer per thread across instances. | +| `upstashLocks` | `withLocks()` | Distributed locks for TanStack AI middleware, such as its sandbox setup. | | `upstashMemory` | `memoryMiddleware()` | Long-term memory ranked in [Redis Search](/docs/redis/search/introduction). | | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | @@ -86556,6 +86565,9 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai npm install @tanstack/ai-persistence @tanstack/ai-memory ``` +Persistence and memory are imported from their own entry points, +`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. + The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. @@ -86566,7 +86578,7 @@ npm install @tanstack/ai-persistence @tanstack/ai-memory ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; -import { upstashPersistence } from "@upstash/agentkit-tanstack-ai"; +import { upstashPersistence } from "@upstash/agentkit-tanstack-ai/persistence"; const persistence = upstashPersistence(); @@ -86632,7 +86644,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ``` -## How to lock a TanStack AI thread across instances +## How to use distributed locks with TanStack AI ```ts import { withLocks } from "@tanstack/ai/locks"; @@ -86641,8 +86653,14 @@ import { upstashLocks } from "@upstash/agentkit-tanstack-ai"; chat({ adapter, messages, middleware: [withLocks(upstashLocks()), withSandbox(sandbox)] }); ``` -A lease that is renewed while the critical section runs. If the lease is lost, the section's -`signal` aborts. +`withLocks` doesn't lock anything by itself. It gives the lock store to later middleware, which lock +the one step they must not run twice: `withSandbox` uses it so two concurrent requests for a thread +don't both create a sandbox, and your own middleware can use it through `getLocks(ctx)`. It does not +serialize whole chat turns. Unlike TanStack's `InMemoryLockStore`, which only works inside one +process, `upstashLocks()` coordinates across instances. + +Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the +section's `signal` aborts. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. @@ -86660,7 +86678,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; -import { upstashMemory } from "@upstash/agentkit-tanstack-ai"; +import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; chat({ adapter, From 6bca677fca74508d9115c7f3664472cfa6a1534e Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 29 Sep 2026 18:01:40 +0300 Subject: [PATCH 13/15] AgentKit TanStack AI: per-section installs, env var source, telemetry note (DX-3081) Claude-Session: https://claude.ai/code/session_01TfqK5vnRTtfrBARXVSuAdf --- llms-full.txt | 98 ++++++++++++++++++----------- redis/sdks/agentkit/tanstack-ai.mdx | 49 +++++++++------ 2 files changed, 90 insertions(+), 57 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index a2c8be170..05f0a175d 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86337,24 +86337,23 @@ across serverless instances, page reloads, and devices. | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | -`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. - ```bash npm install @upstash/agentkit-tanstack-ai @tanstack/ai -# for the features you use: -npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -Persistence and memory are imported from their own entry points, -`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. - - The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + AgentKit reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by default. + Pass a `redis` client to any helper to use a different one. ## How to persist TanStack AI chats in Redis +```bash +npm install @tanstack/ai-persistence +``` + +Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. + ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -86375,12 +86374,12 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads -`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. +`Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you +store generated files. - Runs are indexed by thread, so -reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one -Lua script, so concurrent instances cannot interleave it. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Each write is one command or one Lua script, so concurrent instances cannot interleave it. ```ts @@ -86412,7 +86411,7 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86442,7 +86441,7 @@ process, `upstashLocks()` coordinates across instances. Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86456,6 +86455,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ## How to add long-term memory to TanStack AI +```bash +npm install @tanstack/ai-memory +``` + +Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. + ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; @@ -86477,7 +86482,7 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86511,7 +86516,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. -Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` +from the environment. ## How to add RAG with TanStack AI @@ -86529,7 +86535,12 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. + +## Telemetry + +AgentKit adds its package name and version as a header on your Redis client's requests. To turn it +off, set `UPSTASH_DISABLE_TELEMETRY`, or pass `enableTelemetry: false` to a helper. @@ -86557,24 +86568,23 @@ across serverless instances, page reloads, and devices. | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | -`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. - ```bash npm install @upstash/agentkit-tanstack-ai @tanstack/ai -# for the features you use: -npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -Persistence and memory are imported from their own entry points, -`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. - - The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + AgentKit reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by default. + Pass a `redis` client to any helper to use a different one. ## How to persist TanStack AI chats in Redis +```bash +npm install @tanstack/ai-persistence +``` + +Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. + ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -86595,12 +86605,12 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads -`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. +`Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you +store generated files. - Runs are indexed by thread, so -reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one -Lua script, so concurrent instances cannot interleave it. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Each write is one command or one Lua script, so concurrent instances cannot interleave it. ```ts @@ -86632,7 +86642,7 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86662,7 +86672,7 @@ process, `upstashLocks()` coordinates across instances. Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86676,6 +86686,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ## How to add long-term memory to TanStack AI +```bash +npm install @tanstack/ai-memory +``` + +Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. + ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; @@ -86697,7 +86713,7 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -86731,7 +86747,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. -Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` +from the environment. ## How to add RAG with TanStack AI @@ -86749,7 +86766,12 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. + +## Telemetry + +AgentKit adds its package name and version as a header on your Redis client's requests. To turn it +off, set `UPSTASH_DISABLE_TELEMETRY`, or pass `enableTelemetry: false` to a helper. diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index 9e86125d3..a525d364b 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -18,24 +18,23 @@ across serverless instances, page reloads, and devices. | `toolCache`, `rateLimit` | `middleware` | Skip repeated tool calls; throttle users before the model runs. | | `createSearchTools` | `tools` | `search` / `aggregate` / `count` over your own documents (RAG). | -`upstashPersistence` and `upstashMemory` pass TanStack AI's own backend conformance suites. - ```bash npm install @upstash/agentkit-tanstack-ai @tanstack/ai -# for the features you use: -npm install @tanstack/ai-persistence @tanstack/ai-memory ``` -Persistence and memory are imported from their own entry points, -`@upstash/agentkit-tanstack-ai/persistence` and `@upstash/agentkit-tanstack-ai/memory`. - - The Redis-backed helpers read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` when you don't - pass a `redis` client. Set `UPSTASH_DISABLE_TELEMETRY` to turn off the SDK version header. + AgentKit reads `UPSTASH_REDIS_REST_URL` / `UPSTASH_REDIS_REST_TOKEN` from the environment by default. + Pass a `redis` client to any helper to use a different one. ## How to persist TanStack AI chats in Redis +```bash +npm install @tanstack/ai-persistence +``` + +Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. + ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -56,12 +55,12 @@ import { Bucket } from "@upstash/blob"; const persistence = upstashPersistence({ bucket: Bucket.fromEnv() }); ``` -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. `Bucket.fromEnv()` reads -`UPSTASH_BLOB_TOKEN`, which is only needed when you store generated files. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. +`Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you +store generated files. - Runs are indexed by thread, so -reconnecting to a live run (`findActiveRun`) is a single index read. Each write is one command or one -Lua script, so concurrent instances cannot interleave it. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Each write is one command or one Lua script, so concurrent instances cannot interleave it. ```ts @@ -93,7 +92,7 @@ Every chunk is written to a Redis Stream before it is sent. A client that reconn `Last-Event-ID` (or `?offset`) replays what it missed and keeps following the live run, whichever instance serves the request. Without a `Request`, use `upstashStream({ runId, offset })`. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -123,7 +122,7 @@ process, `upstashLocks()` coordinates across instances. Each lock is a lease that is renewed while the critical section runs. If the lease is lost, the section's `signal` aborts. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -137,6 +136,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. ## How to add long-term memory to TanStack AI +```bash +npm install @tanstack/ai-memory +``` + +Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. + ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; @@ -158,7 +163,7 @@ Before each turn, the most relevant memories for the user's message are added to labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each turn's user message is captured too. Memory is per user across threads by default. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. ```ts @@ -192,7 +197,8 @@ chat({ `rateLimit` fails the run with `RateLimitExceededError` before the model is called. For an HTTP 429 instead, call `createRateLimit({ limiter }).limit(userId)` in your route before `chat()`. -Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Both middlewares and `createRateLimit` read `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` +from the environment. ## How to add RAG with TanStack AI @@ -210,7 +216,12 @@ chat({ adapter, messages, tools }); The tool descriptions are generated from the schema, and the index is created on first use. -Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. +Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. + +## Telemetry + +AgentKit adds its package name and version as a header on your Redis client's requests. To turn it +off, set `UPSTASH_DISABLE_TELEMETRY`, or pass `enableTelemetry: false` to a helper. From 233b4267c9dc7b8f6d5998070cf1798b5ac2fb89 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Tue, 29 Sep 2026 18:10:55 +0300 Subject: [PATCH 14/15] AgentKit TanStack AI: say why the persistence and memory packages are installed (DX-3081) Claude-Session: https://claude.ai/code/session_01TfqK5vnRTtfrBARXVSuAdf --- llms-full.txt | 18 ++++++++++-------- redis/sdks/agentkit/tanstack-ai.mdx | 9 +++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 05f0a175d..e0da417c3 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86348,12 +86348,13 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai ## How to persist TanStack AI chats in Redis +Persistence plugs into TanStack AI's `withPersistence()` middleware, which comes from its persistence +package: + ```bash npm install @tanstack/ai-persistence ``` -Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. - ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -86455,12 +86456,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme ## How to add long-term memory to TanStack AI +Memory plugs into TanStack AI's `memoryMiddleware()`, which comes from its memory package: + ```bash npm install @tanstack/ai-memory ``` -Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. - ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; @@ -86579,12 +86580,13 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai ## How to persist TanStack AI chats in Redis +Persistence plugs into TanStack AI's `withPersistence()` middleware, which comes from its persistence +package: + ```bash npm install @tanstack/ai-persistence ``` -Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. - ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -86686,12 +86688,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme ## How to add long-term memory to TanStack AI +Memory plugs into TanStack AI's `memoryMiddleware()`, which comes from its memory package: + ```bash npm install @tanstack/ai-memory ``` -Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. - ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index a525d364b..583633480 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -29,12 +29,13 @@ npm install @upstash/agentkit-tanstack-ai @tanstack/ai ## How to persist TanStack AI chats in Redis +Persistence plugs into TanStack AI's `withPersistence()` middleware, which comes from its persistence +package: + ```bash npm install @tanstack/ai-persistence ``` -Persistence is imported from `@upstash/agentkit-tanstack-ai/persistence`. - ```ts import { chat } from "@tanstack/ai"; import { withPersistence } from "@tanstack/ai-persistence"; @@ -136,12 +137,12 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme ## How to add long-term memory to TanStack AI +Memory plugs into TanStack AI's `memoryMiddleware()`, which comes from its memory package: + ```bash npm install @tanstack/ai-memory ``` -Memory is imported from `@upstash/agentkit-tanstack-ai/memory`. - ```ts import { memoryMiddleware } from "@tanstack/ai-memory"; import { upstashMemory } from "@upstash/agentkit-tanstack-ai/memory"; From 4edce7410037cf9c34d900c7222e6ffe37747443 Mon Sep 17 00:00:00 2001 From: CahidArda Date: Thu, 1 Oct 2026 12:11:27 +0300 Subject: [PATCH 15/15] AgentKit TanStack AI: install @upstash/redis for RAG; precise findActiveRun and memory scope wording (DX-3081) Claude-Session: https://claude.ai/code/session_01TfqK5vnRTtfrBARXVSuAdf --- llms-full.txt | 20 ++++++++++++++++---- redis/sdks/agentkit/tanstack-ai.mdx | 10 ++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index e0da417c3..0979c1700 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -86379,7 +86379,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme `Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you store generated files. -Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is an indexed lookup, newest run first. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86481,7 +86481,7 @@ chat({ Before each turn, the most relevant memories for the user's message are added to the system prompt, labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each -turn's user message is captured too. Memory is per user across threads by default. +turn's user message is captured too. Memory is per user across threads by default, or per thread when the scope has no `userId`. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. @@ -86522,6 +86522,12 @@ from the environment. ## How to add RAG with TanStack AI +The schema builder `s` comes from `@upstash/redis`: + +```bash +npm install @upstash/redis +``` + ```ts import { s } from "@upstash/redis"; import { createSearchTools } from "@upstash/agentkit-tanstack-ai"; @@ -86611,7 +86617,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme `Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you store generated files. -Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is an indexed lookup, newest run first. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -86713,7 +86719,7 @@ chat({ Before each turn, the most relevant memories for the user's message are added to the system prompt, labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each -turn's user message is captured too. Memory is per user across threads by default. +turn's user message is captured too. Memory is per user across threads by default, or per thread when the scope has no `userId`. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. @@ -86754,6 +86760,12 @@ from the environment. ## How to add RAG with TanStack AI +The schema builder `s` comes from `@upstash/redis`: + +```bash +npm install @upstash/redis +``` + ```ts import { s } from "@upstash/redis"; import { createSearchTools } from "@upstash/agentkit-tanstack-ai"; diff --git a/redis/sdks/agentkit/tanstack-ai.mdx b/redis/sdks/agentkit/tanstack-ai.mdx index 583633480..c89473317 100644 --- a/redis/sdks/agentkit/tanstack-ai.mdx +++ b/redis/sdks/agentkit/tanstack-ai.mdx @@ -60,7 +60,7 @@ Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environme `Bucket.fromEnv()` reads `UPSTASH_BLOB_TOKEN` from the environment, which is only needed when you store generated files. -Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is a single index read. +Runs are indexed by thread, so reconnecting to a live run (`findActiveRun`) is an indexed lookup, newest run first. Each write is one command or one Lua script, so concurrent instances cannot interleave it. @@ -162,7 +162,7 @@ chat({ Before each turn, the most relevant memories for the user's message are added to the system prompt, labelled by where they came from. The model gets a `save_memory` tool for durable facts, and each -turn's user message is captured too. Memory is per user across threads by default. +turn's user message is captured too. Memory is per user across threads by default, or per thread when the scope has no `userId`. Reads `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from the environment. @@ -203,6 +203,12 @@ from the environment. ## How to add RAG with TanStack AI +The schema builder `s` comes from `@upstash/redis`: + +```bash +npm install @upstash/redis +``` + ```ts import { s } from "@upstash/redis"; import { createSearchTools } from "@upstash/agentkit-tanstack-ai";