feat: add Valkey-backed TaskStore and ResumableStreamStore
PR Checklist
Please check if your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://voltagent.dev/docs/community/contributing/#commit-convention
Bugs / Features
- [x] Related issue(s) linked https://github.com/VoltAgent/voltagent/issues/1258
- [x] Tests for the changes have been added
- [x] Docs have been added / updated
- [x] Changesets have been added https://voltagent.dev/docs/community/contributing/#creating-a-changeset
What is the current behavior?
The @voltagent/a2a-server and @voltagent/resumable-streams packages only support in-memory storage. Task state and stream data are lost on restart and cannot be shared across multiple server instances.
What is the new behavior?
Adds Valkey-backed store implementations to both packages using the @valkey/valkey-glide client library:
@voltagent/a2a-server
- New
ValkeyTaskStoreclass implementing theTaskStoreinterface with composite key generation, JSON serialization, and optional TTL-based expiration. createValkeyTaskStorefactory function for easy instantiation.- New
taskStoreoption onA2AServerConfigso a store can be provided at construction time.
@voltagent/resumable-streams
- New
createResumableStreamValkeyStorefactory that wires Valkey pub/sub into the resumable-stream generic context, with per-channel dedicated GlideClient connections and a configurable max subscription limit (default 1000). - TTL support for active stream keys via optional
ttlSeconds. - Exports internal utilities (
markResumableStreamStoreType,buildActiveStreamKey,createActiveStreamStoreFromPublisher,mergeStreamAndActiveStore) for reuse by custom store implementations.
Shared
@valkey/valkey-glideadded as an optional peer dependency in both packages so consumers who don't use Valkey are unaffected.- Both stores support standalone and cluster Valkey deployments, configurable key prefixes, and optional TTL.
Example
- New
examples/with-valkey-storeproject demonstrating end-to-end integration of both stores with a SupportAgent, including environment config template and README.
Tests
- Comprehensive unit tests for
ValkeyTaskStore(load, save, error handling, cancellations, factory function). - Comprehensive unit tests for
createResumableStreamValkeyStore(publisher/subscriber adapters, TTL, subscription limits, close cleanup).
Notes for reviewers
- The
@valkey/valkey-glidepeer dependency is optional, no impact on existing consumers. - The resumable-streams Valkey store creates one dedicated GlideClient per subscription channel, which is a requirement of the Glide pub/sub model. The
maxSubscriptionsoption (default 1000) caps resource usage.
Summary by CodeRabbit
-
New Features
- Valkey-backed storage for task persistence and resumable streams (configurable key prefixes, optional TTL, supports standalone & cluster)
- Example app with a sample assistant and runtime tool demonstrating Valkey integration
-
Documentation
- Added example README, env/sample, package config and run instructions
-
Tests
- New test suites validating Valkey-backed task and resumable-stream stores
-
Breaking Changes
- Server config may now specify a task store that overrides injected defaults (config > deps > in-memory)
๐ฆ Changeset detected
Latest commit: ac74499d657cde2b7dd4570ca0bb170f9105ec2a
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 4 packages
| Name | Type |
|---|---|
| @voltagent/a2a-server | Major |
| @voltagent/resumable-streams | Minor |
| @voltagent/server-elysia | Patch |
| @voltagent/server-hono | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
No actionable comments were generated in the recent review. ๐
โน๏ธ Recent review info
โ๏ธ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1a915acb-ce91-44f3-b241-42aec07acf8e
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 1e845b4c6e80d6a25ab602b0c9f1c68df5b63dfd and ac74499d657cde2b7dd4570ca0bb170f9105ec2a.
โ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
๐ Files selected for processing (23)
.changeset/add-valkey-store-providers.md.gitignoreexamples/with-valkey-store/.env.exampleexamples/with-valkey-store/.gitignoreexamples/with-valkey-store/README.mdexamples/with-valkey-store/package.jsonexamples/with-valkey-store/src/agents/assistant.tsexamples/with-valkey-store/src/index.tsexamples/with-valkey-store/tsconfig.jsonpackages/a2a-server/package.jsonpackages/a2a-server/src/schemas.tspackages/a2a-server/src/server.tspackages/a2a-server/src/types.tspackages/a2a-server/src/valkey-store.spec.tspackages/a2a-server/src/valkey-store.tspackages/a2a-server/tsup.config.tspackages/resumable-streams/package.jsonpackages/resumable-streams/src/resumable-streams.tspackages/resumable-streams/src/valkey-store.spec.tspackages/resumable-streams/src/valkey-store.tspackages/resumable-streams/tsconfig.jsonpackages/resumable-streams/tsup.config.tspackages/resumable-streams/vitest.config.ts
โ Files skipped from review due to trivial changes (10)
- examples/with-valkey-store/.gitignore
- examples/with-valkey-store/tsconfig.json
- packages/resumable-streams/tsconfig.json
- packages/resumable-streams/vitest.config.ts
- .gitignore
- packages/resumable-streams/tsup.config.ts
- examples/with-valkey-store/.env.example
- packages/resumable-streams/package.json
- examples/with-valkey-store/README.md
- .changeset/add-valkey-store-providers.md
๐ง Files skipped from review as they are similar to previous changes (13)
- examples/with-valkey-store/package.json
- examples/with-valkey-store/src/agents/assistant.ts
- packages/a2a-server/tsup.config.ts
- packages/a2a-server/package.json
- packages/a2a-server/src/server.ts
- packages/a2a-server/src/valkey-store.spec.ts
- examples/with-valkey-store/src/index.ts
- packages/a2a-server/src/valkey-store.ts
- packages/resumable-streams/src/valkey-store.ts
- packages/resumable-streams/src/valkey-store.spec.ts
- packages/resumable-streams/src/resumable-streams.ts
- packages/a2a-server/src/schemas.ts
- packages/a2a-server/src/types.ts
๐ Walkthrough
Walkthrough
Adds Valkey-backed task and resumable-stream stores, updates A2A schemas, types, and server task handling, wires package exports and builds, and adds an example app with docs and tests.
Changes
Valkey persistence providers
| Layer / File(s) | Summary |
|---|---|
Schemas, types, and server contract packages/a2a-server/src/schemas.ts, packages/a2a-server/src/types.ts, packages/a2a-server/src/server.ts |
Adds Zod schemas, derives task/message types from them, extends A2AServerConfig with taskStore, and expands VoltA2AError serialization and factories. |
Valkey task store packages/a2a-server/src/valkey-store.ts, packages/a2a-server/src/server.ts, packages/a2a-server/package.json, packages/a2a-server/tsup.config.ts, packages/a2a-server/src/valkey-store.spec.ts, .changeset/add-valkey-store-providers.md |
Adds ValkeyTaskStore and createValkeyTaskStore, wires the new export and peer dependency, updates build inputs, adds tests, and records the package change. |
Resumable stream Valkey store packages/resumable-streams/src/valkey-store.ts, packages/resumable-streams/src/resumable-streams.ts, packages/resumable-streams/package.json, packages/resumable-streams/tsup.config.ts, packages/resumable-streams/tsconfig.json, packages/resumable-streams/vitest.config.ts, packages/resumable-streams/src/valkey-store.spec.ts |
Adds createResumableStreamValkeyStore, exports internal helpers, wires package/build/test config, and adds coverage for publisher, subscriber, and lifecycle behavior. |
Example app and docs examples/with-valkey-store/*, .gitignore |
Adds the Valkey example package, entrypoint, agent, env files, README, and repository ignore updates. |
Sequence Diagram(s)
sequenceDiagram
participant ExampleApp
participant A2AServer
participant ValkeyTaskStore
participant GlideClient
ExampleApp->>A2AServer: initialize(taskStore = ValkeyTaskStore)
A2AServer->>A2AServer: apply taskStore precedence
A2AServer->>ValkeyTaskStore: save(TaskRecord)
ValkeyTaskStore->>GlideClient: set(namespaced key, JSON, expiry?)
GlideClient-->>ValkeyTaskStore: ok
ValkeyTaskStore-->>A2AServer: persisted record
sequenceDiagram
participant ExampleApp
participant ResumableStore
participant PubSubClient
participant GlideClient
ExampleApp->>ResumableStore: createResumableStreamValkeyStore(...)
ResumableStore->>GlideClient: create publisher/subscriber adapters
ResumableStore->>PubSubClient: subscribe(channel, handler)
ResumableStore->>GlideClient: set(active key, stream id, EX?)
ExampleApp->>ResumableStore: close()
ResumableStore->>PubSubClient: close()
Estimated code review effort
๐ฏ 4 (Complex) | โฑ๏ธ ~50 minutes
Poem
๐ฐ I hopped through keys in Valkey green,
A2A tasks and streams now keen.
With schemas, stores, and docs in tow,
The little rabbit watches data flow.
Nibble, twitch, persist โ hooray!
๐ฅ Pre-merge checks | โ 4 | โ 1
โ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 64.71% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
โ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title accurately summarizes the main change: adding Valkey-backed stores for both packages. |
| Description check | โ Passed | The description covers the required checklist, behavior change, tests, docs, and changesets; only the optional fixes/issue line is omitted. |
| Linked Issues check | โ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | โ Passed | Check skipped because no linked issues were found for this pull request. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
@coderabbitai resume
Reviews resumed.โ
Actions performed
Hey @rileydes-improving ๐
Related issue: #1310
I noticed that ValkeyTaskStore accepts a pre-built GlideClient / GlideClusterClient via options.client and doesn't create its own connection. This means CLIENT SETNAME (for connection identification in monitoring tools) needs to be set by the caller when they build the client, rather than inside the store itself.
Would you consider either:
- Documenting in the README/example that callers should set
clientName: "voltagent_a2a_store_client"when creating theirGlideClient, or - Adding a default
clientNamein the example code (examples/with-valkey-store) so users get identifiable connections out of the box?
This makes VoltAgent connections visible in CLIENT LIST, CloudWatch metrics, and monitoring dashboards โ helpful when multiple services share the same Valkey cluster.
Hey @rileydes-improving ๐
Related issue: #1310
I noticed that
ValkeyTaskStoreaccepts a pre-builtGlideClient/GlideClusterClientviaoptions.clientand doesn't create its own connection. This meansCLIENT SETNAME(for connection identification in monitoring tools) needs to be set by the caller when they build the client, rather than inside the store itself.Would you consider either:
- Documenting in the README/example that callers should set
clientName: "voltagent_a2a_store_client"when creating theirGlideClient, or- Adding a default
clientNamein the example code (examples/with-valkey-store) so users get identifiable connections out of the box?This makes VoltAgent connections visible in
CLIENT LIST, CloudWatch metrics, and monitoring dashboards โ helpful when multiple services share the same Valkey cluster.
Already done
Just rebased, tested, and force pushed to make sure it is still current.
@omeraplak You had previously closed the associated issue for this PR, are their changes required for the approach to add proper valkey support?