Skip to content

feat(ai-sdk)!: decouple cache-backed run stores from @rudderjs/cache (#36)#42

Merged
suleimansh merged 1 commit into
mainfrom
decouple/cache-seam
Jun 26, 2026
Merged

feat(ai-sdk)!: decouple cache-backed run stores from @rudderjs/cache (#36)#42
suleimansh merged 1 commit into
mainfrom
decouple/cache-seam

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Closes #36. First child of the @rudderjs decoupling epic #35.

What

  • New CacheAdapter contract (exported) - a 3-method interface (get/set/forget) in src/cache-adapter.ts, the single neutral cache seam for the engine.
  • Run stores take a required BYO cache - CachedAgentRunStore / CachedSubAgentRunStore no longer lazy-import @rudderjs/cache or read a global CacheRegistry. They now require { cache } (typed CacheAdapter); constructing without it throws a clear error. Bring any cache (redis, Memcached, a Map, a framework cache).
  • Google prompt-cache registry made fully neutral too (it already accepted a BYO store): now uses the shared CacheAdapter and a gemstack:ai:google-cache: prefix, zero @rudderjs/cache references.
  • Cleaned the @rudderjs/cache doc mention in types.ts.

Breaking (0.x -> minor)

  • new Cached*RunStore() with no cache now throws; pass { cache }. All in-repo and documented usage already does.
  • Default key prefixes rudderjs:ai:* -> gemstack:ai:*. These guard 5-minute-TTL ephemeral run snapshots, so on upgrade in-flight parked runs fall back to "not found" once (self-heal). Override keyPrefix to keep the old value.

Scope

The only remaining @rudderjs/cache reference in src is the /server provider, which is handled by epic child #39.

Verification

Added cache-required guard tests. Typecheck clean, 979 tests pass. Minor changeset included.

…36)

First child of the @rudderjs decoupling epic (#35).

- New exported neutral CacheAdapter contract (get/set/forget) in
  src/cache-adapter.ts — one source of truth for the cache seam.
- CachedAgentRunStore / CachedSubAgentRunStore no longer lazy-import
  @rudderjs/cache or read a global CacheRegistry. They take a REQUIRED
  caller-supplied { cache } (typed CacheAdapter); construction without it
  throws a clear error. All in-repo + documented usage already passed it.
- Default key prefixes rudderjs:ai:* -> gemstack:ai:* (5-min-TTL ephemeral
  run snapshots; self-heal on upgrade; keyPrefix override available).
- GoogleCacheRegistry (already BYO-store) made fully neutral: aliases the
  shared CacheAdapter, gemstack:ai:google-cache: prefix, no @rudderjs/cache
  references in code or docs. Fixed the in-memory-fallback warning text.
- Cleaned the @rudderjs/cache doc mention in types.ts.

The only remaining @rudderjs/cache ref in src is the /server provider
(tracked under epic child #39).

Added cache-required guard tests. Typecheck clean, 979 tests pass.
@suleimansh suleimansh added the enhancement New feature or request label Jun 26, 2026
@suleimansh suleimansh self-assigned this Jun 26, 2026
@suleimansh suleimansh merged commit e784b5d into main Jun 26, 2026
1 check passed
@suleimansh suleimansh deleted the decouple/cache-seam branch June 26, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ai-sdk decouple: cache seam — drop @rudderjs/cache lazy fallback (BYO CacheAdapter)

1 participant