Repository navigation
Conversation
Squash of PR #38 (feat/list-models) by edge.xyz onto devin/hub-api. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…nly) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… honor configured restrictions Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…2852-hub-list-models
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…2852-hub-list-models
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
klarkxy
reviewed
Nov 24, 2026
klarkxy
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed via Gemini App · Model: Gemini · Commit:
6ea25c9d98ecf8e45308a01ed510d162ef857b36
整体评估
本 PR 将 #38 的按需 Worker 模型目录发现(list_models)完整移植到中心 Hub 服务层(GET /v1/agents/{agent}/models),实现了多协调器共享 TTL 缓存、在途探测防空闲自退(_model_discoveries)、与真实派发一致的 session_meta 白名单继承,以及严格的管理端权限边界(拒绝 abw_* Worker Token、Dashboard Cookie 与 remote.py 网关),4 平台 CI 全绿。审查发现 3 处协议解析、工作区副作用与 URL 参数编码缺陷,建议修复后再合入。
1. 建议修复(逻辑缺陷 / 潜在风险)
-
_acp_model_catalog漏判无category的id="effort"选项,且未过滤原生 DSH 的空字符串默认项""- 位置:
src/agent_bridge/adapters/acp.py第 723–731 行(_acp_model_catalog) - 触发条件与影响:
- 漏判 Claude Code 推理档位:当前条件
option.category == "thought_level" or option.id in {"thinking", "reasoning_effort"}未包含"effort"与"reasoning"。对照本仓库真实夹具tests/test_claude_acp.py及同文件_cursor_effort_option_ids,claude-agent-acp返回的档位选项为id="effort"且不带category,真实运行时会导致supported_efforts静默丢失为None; - 暴露非法空字符串档位
"":原生dsh --profile acp(见tests/test_dsh_acp.py)的reasoning_effort.options首项为{"value": "", "name": "Provider default"},当前未过滤空串,导致list_models返回["", "low", "high", "max"],协调器若原样回传effort=""会被validate_selection抛ValueError拒绝。
- 漏判 Claude Code 推理档位:当前条件
- 修改建议:将
option.id匹配集合对齐为{"thinking", "effort", "reasoning", "reasoning_effort"},并在提取候选值时过滤空字符串(cleaned = [v for v in offered if v]),补充对应单测。
- 位置:
-
旧版
dsh-acp-demo执行只读list_models探测时未隔离DSH_SNAPSHOT_SESSIONS_ROOT,会在用户项目目录下创建./.sessions- 位置:
src/agent_bridge/adapters/acp.py第 782–783、797–809 行(AcpAdapter.list_models) - 触发条件与影响:常规派发在
_spawn中传入了session_id以将dsh-acp.cordis.yml的persistenceRoot重定向至$AGENT_BRIDGE_HOME/dsh-sessions/<session_id>;而list_models调用prepare_dsh_launch(cmd, env)时未传session_id且在用户cwd下执行session/new,导致标注为只读的模型发现操作在用户项目工作区写入.sessions/目录。 - 修改建议:对
self.agent.name == "dsh"且非原生--profile acp的探测子进程显式注入指向self.home下临时目录的DSH_SNAPSHOT_SESSIONS_ROOT,并在_cleanup_discovery中清理。
- 位置:
-
HubClient._call拼接路径参数未做 URL 编码,特殊字符agent名可引发格式化异常或路径偏移- 位置:
src/agent_bridge/hub_client.py第 27、65–66 行(ROUTES['list_models']与HubClient._call) - 触发条件与影响:
path = path.format(**{key: kwargs.pop(key)})直接拼接原始字符串;当agent含{/}时会在客户端抛KeyError/ValueError,含/、..、?、#时则会偏离/v1/agents/{agent}/models路由或污染查询串。 - 修改建议:校验路径参数非空且不为
./..后,使用urllib.parse.quote(str(val), safe="")替换路径占位符。
- 位置:
2. 建议改进(边界条件 / 健壮性)
Registry.stop()主动取消并等待在途探测任务(src/agent_bridge/registry.py第 186、556–600、653–682 行):建议将_model_discoveries从整型计数器改为set[asyncio.Task],在stop()中取消并等待在途探测子进程回收完毕,避免进程退出时残留未收尾子进程。scripts/smoke_models.py沙箱环境变量隔离(第 45–50 行):建议在StdioServerParameters.env中显式设置"AGENT_BRIDGE_HUB": "off"并清空"AGENT_BRIDGE_HUB_URL",防止宿主环境变量导致冒烟脚本误连外部运行中的 Hub。_acp_model_catalog字典兼容与未枚举default_model处理(adapters/acp.py第 711–721 行):建议统一通过_dump(option)访问字段,并对不在候选models列表中的占位默认值(如"default")做置空或告警提示。
3. 小细节(Nits)
- 文档与诊断细节:
README.md中文工具表漏列list_models;codex_app_server_list_models(model_discovery_exec.py第 129 行)建议保留脱敏后的stderr尾部以便排查-c配置错误;Hub 路由缺省cwd查询参数时可前置校验以返回更清晰的400提示。
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.
Summary
把 #38(作者 @edgexyz)的按需模型发现移植到 Hub 重构(#42,已合并到
main)上,并改走 Hub 服务层。原 #38 分支未改动。提交结构
7303c68:Add on-demand worker model discovery through MCP #38 内容 squash 合入,作者保留为 edge.xyz;解决了config.py(hub+models两个配置节并存)、SKILL.md、test_server_tools.py的冲突。f426c30:Hub 接入。8ea094f:模型发现进行中不触发空闲退出(审查发现)。78281a9:探测会话使用与派发相同的 session/new 元数据,列出的模型遵守配置的限制(审查发现)。5c23f74:补充 worker token 访问模型发现路由返回 403 的测试。devin/hub-api/main的合并提交;base 已改为main。Hub 接入
refresh和active_only一样严格解析true|false,其他值返回 400。审查修复
session_meta(与不指定模型的派发完全一致),worker 按同样配置(如 Claude 模型白名单)给出模型列表,列出的模型都能派发。代价是session_meta里固定的modelId会成为探测报告的default_model,这与派发实际默认值一致。安全边界(仅本机、仅管理员)
remote.py未添加该路由(测试断言返回 404)。coordinator.dispatch_enabled=true可用、cwd 必须是已存在的绝对路径、超时、诊断信息脱敏。测试
test_list_models_route(含 401/403/400 用例)、test_list_models_unsupported;test_remote.py增加远程网关 404 用例。test_idle_exit_waits_for_inflight_discovery、test_claude_discovery_honors_session_meta_model_allowlist、test_discovery_meta_matches_default_dispatch。main为 base 时 CI 四个平台全部通过;本地pytest、ruff、mypy src通过。文档:
HUB.md、HUB.zh-CN.md、SETUP.md补充了路由说明。Implemented in session Port worker model discovery onto hub
Review with Devin · Open in Devin Desktop