fix(tui): degrade Moonshot tool schema failures per tool - #22
Merged
h3c-hexin merged 2 commits intoAug 27, 2026
Merged
Conversation
|
Thanks @qiuYliangM for taking the time to contribute. This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered. Please read |
Upstream sanitize_moonshot_chat_tools failed the whole request before transport when any tool's parameters failed MFJS compatibility validation. One third-party MCP server whose schema uses keywords outside the MFJS whitelist (e.g. $schema, pattern) therefore broke every Moonshot-routed turn, including turns that never called the tool. Change the sanitizer to per-tool degradation: a tool whose parameters cannot pass validation is dropped from the current request with a tracing warning that names the tool but, like the error Display, carries no schema values. When every tool is dropped, the tools and tool_choice keys are omitted so an empty array or a dangling choice cannot trigger a fresh 400. Preview and actual sends stay consistent because both go through build_chat_wire_body. The two upstream fail-before-transport tests are rewritten to assert the new behavior (request sends, offending tool absent from the wire body, private schema values never leak), and a new forkguard_moonshot_drops_only_incompatible_tool locks the per-tool degradation contract. Agent-assisted change (Kimi Code CLI); root-cause analysis and fix plan: docs/mcp-schema-moonshot-mfjs-analysis.md in the parent repo. Signed-off-by: Lfanxing <1461574375@qq.com>
当具名 tool_choice 指向被 MFJS 兼容性检查淘汰的工具时,在发送前返回不含 schema 内容的明确错误,避免生成悬空选择。 对普通按工具降级请求,在流开始前发出一次结构化警告;TUI 通过本地化 warning toast 展示,runtime 记录带稳定诊断码的 status item,且诊断事件不改变透明重试的内容判定。 新增具名选择和单次可见警告回归测试,并补齐完整语言包。 Signed-off-by: hexin <372726039@qq.com>
h3c-hexin
force-pushed
the
fix/moonshot-mcp-tool-degrade
branch
from
August 27, 2026 02:15
70befd8 to
8f49fb8
Compare
3 tasks
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.
Background
A third-party MCP server can expose a tool schema that Moonshot's MFJS validator cannot accept (for example, a schema containing
pattern). Because the complete active tool surface is sent with each model request, failing the whole request on one incompatible tool makes unrelated Moonshot/Kimi turns unusable.Changes
toolsandtool_choicewhen no compatible tool remains.tool_choicelocally when it targets an omitted tool, instead of sending a dangling choice. The user-visible error includes the tool name but never schema values.provider_tool_projection_warningcode.build_chat_wire_bodypreparation seam.Verification
cargo fmt --all -- --checkcargo test -p codewhale-tui --lib forkguard_moonshot -- --nocapture— 3 passedcargo test -p codewhale-tui --lib --locked forkguard_ -- --test-threads=1— 45 passedcargo test -p codewhale-tui --lib drops_— 48 passedcargo test -p codewhale-tui --lib localization::tests::— 32 passedKnown limits
tool_choice, request preview, diagnostics, and dispatch validation in one upstream-owned seam.No-Issue: issues are disabled on this fork repository. The general design will be tracked in the upstream repository.