Repository navigation
feat: /mcp 状态与手动重连;定价表外置 ~/.corecoder/pricing.json - #37
Merged
Merged
Conversation
A dead MCP server used to stay dead until the whole session restarted. The client now keeps its spawn spec, so reconnect() can close the old process, start a fresh one and redo initialize + tools/list; the mcp__ tools the agent already holds route through the client, so they work again the moment the new handshake lands. The reader thread guards on its own process, so a reader left over from before a reconnect cannot mark the new process dead. The REPL grows /mcp: list each server with its state and tool count, or /mcp reconnect <name> to revive one by hand. No auto-reconnect: a manual trigger keeps the client free of retry policy.
estimated_cost used to read only the hardcoded _PRICING table, so a new model or a moved price meant waiting for a release. _load_pricing() now overlays the user's pricing.json (same shape) on the built-ins, and a missing or broken file quietly means the built-ins.
The sweep keys were str(relative_to) which is backslash-formed on Windows, so every forward-slash doc reference failed to resolve there. as_posix() keeps the keys slash-formed on all platforms. Windows legs on main have been red on this since c941e87.
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.
Roadmap #35 的第六、七项,两个 commit 各绿一套测试。
/mcp状态与手动重连。 server 进程死了以前是静死的:tool 还在列表里,调用才报错。现在/mcp列出每个 server 的存活状态和死因,/mcp reconnect <name>关掉旧进程重跑握手;agent 持有的mcp__工具路由走 client 不走近程,重连成功即恢复,agent 侧零改动。实现上把 spawn 从__init__拆成_start(),读线程按进程实例把守(proc is self._proc),旧读线程不会在重连后把新进程误标 dead。不做自动重连:手动触发不会风暴,自动重连要回答的退避问题这轮不想答。定价表外置。
estimated_cost每次调用时读~/.corecoder/pricing.json覆盖内置表,新模型调价不用等发版。整个文件有任何坏条目即静默回落内置表,不做逐条目容错:半坏的覆盖表比没有更危险。无缓存无刷新,12 行。测试:224 passed(基线 215 + 9 新)。MCP 侧用 stdin/stdout 念 JSON-RPC 的假 server,
crash工具os._exit(1)模拟死亡,覆盖 crash 重连后旧 tool 对象直接可用、重连失败保持 dead 等 5 例;pricing 侧覆盖优先、扩新模型、三种损坏形态回落。conftest 加了 autouse 隔离,PRICING_FILE指向 tmp,真机文件进不了测试。文档按 doc-pin 测试要求同步:README 双语、article 00/03/06/08 双语的行数钉和功能句。
顺带修了一个 main 上的存量红:doc 行数钉的 sweep 用
str(relative_to)当键,Windows 上是反斜杠,所有正斜杠引用全部解析失败,Windows 四条腿从 c941e87 起一直红。改为as_posix(),一行。