Skip to content

agent: align subagent tool surface with runtime#4514

Merged
SivanCola merged 2 commits into
esengine:main-v2from
lifu963:pr/subagent-tool-surface
Jun 16, 2026
Merged

agent: align subagent tool surface with runtime#4514
SivanCola merged 2 commits into
esengine:main-v2from
lifu963:pr/subagent-tool-surface

Conversation

@lifu963

@lifu963 lifu963 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 新增统一的 subagent tool registry 构造入口,所有 subagent 路径都会先规范化工具面。
  • 在 subagent 中过滤掉会再次触发 agent/skill 调度的工具,例如 taskrun_skillread_skillinstall_skillinstall_sourceexploreresearchreviewsecurity_review,避免 subagent 递归启动新的 agent 工作流。
  • 在 subagent 中过滤后台 job 管理工具:waitbash_outputkill_shell
  • 将 subagent 可见的 bash 包装为 foreground-only:schema 不再暴露 run_in_background;普通前台命令仍正常执行;如果仍传入 run_in_background=true,会返回明确的 subagent 专用错误。
  • 该规范化覆盖 task subagent、skill subagent,以及直接 CLI review subagent 路径。

Why

Subagent 当前不注入后台 job manager,因此它无法真正启动或管理跨 turn 的后台任务。之前 subagent 可能继承 parent registry 中的 waitbash_outputkill_shell,也可能看到包含 run_in_backgroundbash schema。结果是模型会认为这些能力可用,但调用时只能在 jobs.FromContext 处失败,出现泛化的 background execution is not available in this context 之类错误。

这违反了“工具 schema 应代表真实可用能力”的原则。本次改动让 subagent 的工具说明与实际 runtime 能力一致:不可用的后台 job 工具不再出现在工具列表里;bash 只声明前台能力;误传后台参数时返回更明确的错误,提示应运行前台命令或让 parent agent 启动后台任务。

Result

  • Parent agent 的后台任务能力保持不变。
  • Subagent 不再看到实际 runtime 不支持的后台 job 能力。
  • 模型更少因为错误工具面做无效调用。
  • 出错时错误信息更具体,更容易自我修正。

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) labels Jun 15, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator

Follow-up pushed in e79f4c1.

What changed:

  • Updated the task tool description/schema to mention subagent job-tool filtering and foreground-only bash.
  • Added regression coverage for that provider-visible boundary text.

Verified:

  • go test ./internal/agent ./internal/boot ./internal/cli passed.

@SivanCola SivanCola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

approve

@SivanCola SivanCola merged commit 211a9a8 into esengine:main-v2 Jun 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants