Repository navigation
Key the tool response cache by tool id and nested params - #1308
Merged
Merged
Conversation
helpcodeai
enabled auto-merge (squash)
October 28, 2026 08:25
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
The tool response cache (
responseMapping.cacheTtl) built its key from the tool name and a hash of the parameters. Two problems:JSON.stringify(params, sortedTopLevelKeys). A replacer array filters keys at every depth, so nested parameters were dropped:{ filter: { status: 'open' } }and{ filter: { status: 'closed' } }got the same key.The key is now
tool_cache:v3:<toolId>:<scope>:<hash>, with the parameters hashed with keys sorted at every depth (the existinghashContenthelper). The prefix bump means v2 entries are never read again and simply expire.Changes
buildCacheKeytakes the registered tool and uses its id instead of its name.hashContent(recursive key sort, sha256).Type
Testing
Commands, in
packages/backendafternpm ciandprisma generate:npx jest src/mcp-server/dynamic-mcp-tools: 2 suites, 105 tests passed.dynamic-mcp-tools.ts: 3 failed (the two new tests and the key prefix check).npx tsc --noEmit -p tsconfig.json: clean.npx eslinton the two changed files: clean.Behaviour in Cloud and self-hosted is the same. After the deploy, cached tools miss once and refill under the new keys.
Checklist
Related Issues
Relates to #1296