fix(agent-cache): include tool definitions in cache key for Vercel an…#233
Open
KIvanow wants to merge 1 commit into
Open
fix(agent-cache): include tool definitions in cache key for Vercel an…#233KIvanow wants to merge 1 commit into
KIvanow wants to merge 1 commit into
Conversation
…d LlamaIndex adapters The Vercel AI SDK and LlamaIndex adapters were not including tool definitions in the cache key, so requests with identical messages but different tools could return the same cached response. This also adds seed, stopSequences, responseFormat, and toolChoice to the Vercel adapter key. LlamaIndex prepareParams/prepare_params now accepts a tools option. The call closure is never serialized; only metadata (name, description, parameters) is used. Omitting tools falls back to messages-only keying (prior behavior). Tool-using requests will produce different keys than before, causing a one-time cache miss on upgrade. This is intended. Includes divergence/stability tests for all three fixed paths (Vercel TS, LlamaIndex TS, LlamaIndex Python) and updated changelogs and docs.
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.
Summary
Include tool definitions (and other missing generation parameters) in the cache key for the Vercel AI SDK and LlamaIndex adapters. Previously, identical messages with different tools could return the same cached response on these adapters.
Changes
Breaking/behavioral note: tool-using requests on these adapters will produce different keys than before, so existing cached entries for those requests will be a one-time miss after upgrade. This is intended -- the prior entries were not safe to reuse across differing tool sets.
Checklist
roborev review --branchor/roborev-review-branchin Claude Code (internal)Note
Medium Risk
Changes cache key semantics for tool-using LLM requests (intentional one-time misses); incorrect keys previously risked stale wrong answers, so rollout should be monitored on cached agent paths.
Overview
Fixes incorrect LLM cache hits where the same messages could share a cached response despite different tools or generation settings on the Vercel AI SDK and LlamaIndex adapters (TS and Python).
The Vercel middleware now maps
tools,toolChoice,seed,stopSequences, andresponseFormat(plusmaxOutputTokens) intoLlmCacheParams, converting AI SDK tool shapes to the canonical{ type, function: { name, parameters } }form. LlamaIndexprepareParams/prepare_paramsgains an optionaltoolsargument that serializes only tool metadata (name, description, parameters), notcallclosures.0.7.0 changelogs and agent-cache docs note a one-time cache miss for tool-using requests after upgrade (old keys were unsafe). LangChain is unchanged; docs call out that
BaseCachecannot include tools in the key. New adapter key-divergence tests cover tool sensitivity, order invariance (via core hash sorting), and closure safety.Reviewed by Cursor Bugbot for commit 52068ba. Bugbot is set up for automated code reviews on this repo. Configure here.