fix: respect caching: false on wrapAISDKModel#396
Open
Sraleik wants to merge 1 commit into
Open
Conversation
The local `caching` flag was being read at the top of `wrapAISDKModel` but never checked inside `wrapGenerate`/`wrapStream`. The cache fetch/store paths were gated only on the existence of `cacheContext`, which made `caching: false` a silent no-op as long as tracing was enabled (the default). Add `&& enableCaching` to the four cache fetch/store guards in ai-sdk.ts. Tracing path is unchanged. Closes mattpocock#395 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@Sraleik is attempting to deploy a commit to the Skill Recordings Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 8f2deed The changes in this PR will be included in the next version bump. 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix the
caching: falseoption onwrapAISDKModel, which was silently ignored.Closes #395.
Why
wrapAISDKModel(model, { caching: false })reads the flag at the top of the function but never checks it inside the wrapper. The cache fetch and store paths are gated only onif (cacheContext), so as long as tracing is enabled (default), the cache is read and written regardless of what the user passed.This is misleading: the API suggests opt-out is supported, but the only way to truly bypass the cache today is to also disable tracing (which makes
wrapAISDKModelshort-circuit and return the unwrapped model). Users running cross-model baselines or measuring sampling variability acrosstrialCount > 1silently get cached responses.Change
Four sites in
packages/evalite/src/ai-sdk.ts— two inwrapGenerate, two inwrapStream:The early-return
if (!enableCaching && !enableTracing) return model;is unchanged. Tracing path is untouched. Whencaching: true(default), behavior is identical to before.Tests
ai-sdk-caching.test.tstests still pass.Should respect caching: false on wrapAISDKModel even when global cache is enabled.packages/evalite-tests/tests/fixtures/ai-sdk-caching-local-disabled/— same shape asai-sdk-cachingbut wraps both task and scorer models with{ caching: false }. Asserts that two consecutive runs produce zero[CACHE]log lines, demonstrating that neither cache fetch nor store happened.Changeset
patchbump forevalite. See.changeset/wrap-aisdk-respect-caching-flag.md.Out of scope (mentioned for context)
The companion bug — that the CLI flag
--no-cacheand configcache: falseonly short-circuit thereportCacheHitcallback inevalite.tsrather than skipping thecacheContextLocalStorage.enterWith()call — is not addressed here. That's a more invasive change touchingevalite.ts+ types, and I think it deserves its own PR. Happy to follow up if you'd like; flagged as a note in #395.