Skip to content

fix(agent_mcp): fail fast when stopped experts are called - #2470

Open
huangcheng wants to merge 3 commits into
TencentCloud:developfrom
huangcheng:fix/agent-mcp-stopped-expert-errors
Open

huangcheng wants to merge 3 commits into
TencentCloud:developfrom
huangcheng:fix/agent-mcp-stopped-expert-errors

Conversation

@huangcheng

@huangcheng huangcheng commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Stopped experts called via Agent MCP (or any stream path) used to raise harness KeyError and get rendered as 「模型调用失败:'agent_id'」, sending integrators down the wrong rabbit hole.
  • Fail fast with AGENT_NOT_RUNNING / new AGENT_DISABLED, classify bare KeyError(agent_id) stream errors, guard AgentManager.stream/call/resume_hitl via get_agent, and surface MCP error.code (+ unified status: failed shape).

Companion PRs

Test plan

  • uv run pytest tests/unit/agent_mcp tests/unit/i18n/test_stream.py tests/unit/i18n/test_errors.py -q
  • MCP call_octop_expert on a stopped expert returns isError + error.code=AGENT_NOT_RUNNING (not model-call wording)
  • Disabled expert returns AGENT_DISABLED
  • Running expert path unchanged

Stopped experts were raising harness KeyError and surfacing as a misleading
model-call failure. Precheck runtime via get_agent, split AGENT_DISABLED,
classify KeyError stream errors, and expose MCP error codes.
@jubaoliang

Copy link
Copy Markdown
Collaborator

🔍 本 PR 自动检查发现的问题

  • ❌ CI Workflow 未通过:当前存在失败的 check,请先修复到全绿

以上为 automated 检查提示,请补充后 @ 我重新评审。

stream/resume_hitl now precheck via get_agent; SimpleNamespace fakes without
it raised AttributeError and left serialization tests waiting forever (CI 6h).
@huangcheng

Copy link
Copy Markdown
Contributor Author

@jubaoliang CI hung for 6h because two unit fakes used SimpleNamespace harness stubs without get_agent. After stream/resume_hitl started prechecking via get_agent, test_stream_and_resume_hitl_serialize_per_thread waited forever on entered.wait().

Fixed in 4a320bf (stub get_agent on those fakes). Please re-review once CI is green.

This branch has not been deployed

No deployments
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.

2 participants