Skip to content

fix(mcp): 修复非 UUID Agent ID 无法解析的问题 - #2422

Merged
lyingbug merged 1 commit into
Tencent:mainfrom
ZhuangShiHao1207:fix/mcp-resolve-nonuuid-agent-id
Jul 30, 2026
Merged

fix(mcp): 修复非 UUID Agent ID 无法解析的问题#2422
lyingbug merged 1 commit into
Tencent:mainfrom
ZhuangShiHao1207:fix/mcp-resolve-nonuuid-agent-id

Conversation

@ZhuangShiHao1207

Copy link
Copy Markdown
Contributor

问题描述

使用MCP来调用工具list_agents 会返回内置 Agent 的 ID(例如 builtin-wiki-researcher),但该非 UUID ID 传给 agent_chatget_agent 时会被解析失败并报“Agent not found”。

根因是 resolve_agent_id 对非 UUID 入参仅按 Agent 的 name(忽略大小写)匹配,未按 id 匹配。

变更类型

  • 🐛 Bug fix

修复内容

  • 对非 UUID 入参优先精确匹配 Agent 的 id
  • 未匹配时保留原有按 name 忽略大小写匹配的行为。
  • 更新函数说明,使其准确描述支持 ID 与名称两种输入。

测试

  • 新增 builtin-wiki-researcher 可按非 UUID ID 解析的回归测试。
  • 覆盖原有按名称、忽略大小写解析的兼容行为。
  • 执行 pytest,结果:2 passed

检查清单

  • git diff --check origin/main...HEAD 通过
  • 已新增覆盖本次修复的单元测试
  • 已完成自查

Copilot AI review requested due to automatic review settings July 30, 2026 08:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes MCP agent resolution so that non-UUID agent identifiers returned by list_agents (e.g. builtin-wiki-researcher) can be correctly used with APIs like agent_chat / get_agent, by enhancing resolve_agent_id to match both agent id and name.

Changes:

  • Update resolve_agent_id to (for non-UUID input) first match agent id exactly, then fall back to case-insensitive name matching.
  • Update the resolve_agent_id docstring to reflect support for both ID and name inputs.
  • Add regression tests covering non-UUID ID resolution and the existing case-insensitive name resolution behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
mcp-server/weknora_mcp_server.py Fix agent resolution logic to support exact matching on non-UUID agent IDs before falling back to name matching.
mcp-server/tests/test_agent_id_resolution.py Add pytest regression coverage for non-UUID agent IDs and case-insensitive name matching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lyingbug
lyingbug merged commit b67ed27 into Tencent:main Jul 30, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants