Repository navigation
Conversation
edgexyz
marked this pull request as ready for review
October 21, 2026 09:48
klarkxy
reviewed
Nov 25, 2026
klarkxy
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed via Gemini App · Model: Gemini · Commit:
d3a6f498599c717b04b2387a4cbcbda42d495468
整体评估
本 PR 设计并实现了按需探测本地 Worker 模型目录与原生推理档位的 list_models 机制(清晰区分 supported_efforts 的 None 与 [],并通过 asyncio.shield 保障超时/取消时的子进程回收)。由于仓库 main 分支已合入中心化重构 PR #42(20a0882a),而关联移植 PR #45 已在保留原作者署名的前提下将该能力迁移至中心 Hub 服务层(并先行修复了 idle_exit_due 空闲误退与 session_meta 模型白名单透传),建议不直接合入 #38,待下方审查发现的遗留问题同步修复至 #45 并合入后关闭本 PR。
1. 建议修复(架构冲突与需同步至 #45 的逻辑缺陷)
-
与
main中心 Hub 架构冲突,应由移植 PR #45 承接- 位置:
src/agent_bridge/server.py、src/agent_bridge/config.py:483 - 触发场景:当前
main(50f154f2)已将全部工具调用收敛至_service(ctx)与本机 Hub HTTP API;本分支直接调用本地_registry(ctx).list_models(...)不仅存在多文件合并冲突(mergeable_state: "dirty"),在多协调器场景下还会绕过 Hub 共享缓存与管理员鉴权。
- 位置:
-
_acp_model_catalog漏判无category的id="effort"/"reasoning"档位选项,且未过滤原生 DSH 的空字符串默认项""(同样存在于#45,建议移植修复)- 位置:
src/agent_bridge/adapters/acp.py:723-731 - 触发场景:
- (a) 代码仅匹配
option.category == "thought_level" or option.id in {"thinking", "reasoning_effort"}。但真实claude-agent-acp返回的id="effort"选项不含category字段(参见tests/test_claude_acp.py夹具),导致实测调用list_models("claude", ...)时默认模型的supported_efforts静默丢失为None; - (b) 原生
dsh --profile acp的reasoning_effort.options首项为{"value": "", "name": "Provider default"}(参见tests/test_dsh_acp.py),未过滤空字符串会使返回的supported_efforts混入非法空串""。
- (a) 代码仅匹配
- 具体修改建议:将
option.id匹配集合扩展为{"thinking", "effort", "reasoning", "reasoning_effort"},并对候选值过滤空字符串(cleaned = [v for v in offered if v])。
- 位置:
-
旧版
dsh-acp-demo执行只读list_models时未隔离DSH_SNAPSHOT_SESSIONS_ROOT,直接污染用户业务项目根目录(建议同步至#45修复)- 位置:
src/agent_bridge/adapters/acp.py:782-783, 796-809(配合src/agent_bridge/dsh_home.py的prepare_dsh_launch) - 触发场景:
list_models标注为READ_ONLY,但调用prepare_dsh_launch(cmd, env)时未传入session_id,导致未注入DSH_SNAPSHOT_SESSIONS_ROOT,使旧版dsh-acp-demo在执行new_session时直接在用户项目cwd下创建./.sessions/目录及空会话文件。 - 具体修改建议:在
self.home下分配专用临时会话目录注入env["DSH_SNAPSHOT_SESSIONS_ROOT"],并在_cleanup_discovery中清理。
- 位置:
2. 建议改进(建议一并同步至 #45)
- 细化
_model_locks并发锁粒度并合并并发刷新(src/agent_bridge/registry.py:173, 621-626):当前锁按agent粗粒度互斥且位于asyncio.timeout(timeout_sec)内部,不同项目cwd同时首次探测慢速 Worker 时易在等锁阶段超时,且并发refresh=True会重复拉起两次子进程;建议改为按(agent, resolved)的 single-flightFuture合并在途探测。 - 保留
codex app-server的stderr尾部诊断并补齐parse_codex_models结构校验(src/agent_bridge/model_discovery_exec.py:23-36, 48-55, 129、tests/test_model_discovery_exec.py:105, 301):捕获codex app-server的限长stderr经redact_diagnostic附入异常消息;在parse_codex_models中校验isinstance(entry, Mapping)与字符串id,并将测试夹具中已编写但漏挂的"malformed"加入@pytest.mark.parametrize。
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.
Coordinators currently need to inspect individual worker CLIs to find model IDs before dispatching. This adds an on-demand MCP tool,
list_models(agent, cwd, refresh=false), that returns a worker's advertised model catalog.list_agentsalso reports discovery support.Changes
initialize/session/newhandshake and the SDK's typed configuration options.agy modelsand Codex through paginated app-servermodel/list.nullfor unknown effort support and[]for explicitly empty levels.[models] cache_sec/timeout_secconfiguration.Discovery is available to coordinator instances. ACP discovery denies permission requests and may leave an empty session in worker history. Lookup deadlines, output/page limits, diagnostic redaction, and subprocess cleanup cover worker failures and cancellation.
Validation
Tested on Windows with Python 3.14:
ruff check .andmypy: passed.The full suite reports one previously observed asyncio pipe-finalizer warning in
test_quota.py::test_describe_quotas_covers_every_agent; all tests pass.