feat: MCP cache-stable canonicalization — deterministic tool order and schema key sorting | MCP 缓存稳定化#2189
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f520f05495
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6426b6823f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6212f5e0ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Part of the #2188–#2192 stack that currently shows the same cumulative +1740/-39 diff on all five PRs (all based on |
6212f5e to
d99ee7d
Compare
esengine
left a comment
There was a problem hiding this comment.
Reviewed — semantically safe and squarely aligned with the cache-first design. canonicalizeSchemaForCache recursively sorts object keys (insignificant in JSON) and sorts only set-like scalar arrays (required/dependentRequired, where order carries no meaning), while leaving order-significant arrays like enum untouched — and tools are sorted by registered name. So tool/schema content is preserved; only the serialization order is stabilized, which is exactly what makes the DeepSeek prefix-cache fingerprint deterministic across sessions. Good win for cache hit rate. CI green, test added. Merging.
Summary
Stabilizes MCP tool specs before registration so the DeepSeek prefix cache fingerprint is deterministic across sessions. Tools are sorted by final registered name; schema object keys are recursively stabilized; set-like arrays (required, dependentRequired) are sorted while ordered arrays (enum, oneOf, anyOf, allOf) preserve their original order. Enabled by default with no user-facing config switch.
概述
在注册前稳定化 MCP tool specs,使 DeepSeek 前缀缓存指纹在会话间保持确定性。按最终注册名排序工具;递归稳定化 schema 对象键;排序 set-like 数组(required, dependentRequired),保留有序数组(enum, oneOf, anyOf, allOf)的原始顺序。默认启用,无用户配置开关。
Key Files
src/mcp/registry.ts—canonicalizeMcpToolForCache(),canonicalizeSchemaForCache()tests/mcp-cache-canonicalization.test.ts(new) — unit testsDepends On / 依赖
This PR is #2 in a 5-PR series:
plan-resumedrole from ink to frame #5: SSH Remote Workspace RFCTest Plan
Verification