Skip to content

allowed-tools: Bash(agent-browser:*) 衍生的 Chrome 子进程在会话中断后变成孤儿进程 #29856

Closed as not planned

Description

@1247934718gg-design

Description

agent-browser skill 通过 allowed-tools: Bash(agent-browser:), Bash(npx agent-browser:) 授权 AI 执行 agent-browser 命令。agent-browser 的设计是持久化浏览器模型 — 启动 Chrome 后进程持续运行,跨多个 CLI 命令复用同一实例,直到显式调用 agent-browser close。
问题现象:

  • AI 执行 agent-browser open → Chrome 进程启动
  • 对话被中断/超时/异常退出 → AI 没机会执行 agent-browser close
  • Chrome 进程成为孤儿进程残留
    根因:
    opencode 的 Bash tool 在持久 shell 会话中执行命令,Chrome 被 daemonize 后脱离 shell 进程组。对话结束时,Bash tool 没有任何机制清理衍生子进程。
    对比:
    Claude Code 的 tool 沙箱对衍生进程有生命周期管理(进程退出时自动清理子进程组),因此同样 skill 不会出现此问题。
    修复建议(二选一):
  1. Bash tool 在会话结束时 kill 所有衍生子进程(进程组 cleanup)
  2. 提供类似 cleanup hook 或 trap 机制,让 skill 能注册退出时的清理命令

Plugins

allowed-tools: Bash(agent-browser:*)

OpenCode version

1.15.11

Steps to reproduce

  1. 加载 agent-browser skill
  2. 执行 agent-browser open https://example.com
  3. 中断对话(Ctrl+C 或自然结束)
  4. ps aux | grep -i chrome 可见残留 Chrome 进程

Screenshot and/or share link

No response

Operating System

macos26.4

Terminal

No response

Activity

  1. github-actions commented on May 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is specifically about the orphaned Chrome process not being cleaned up (rather than the bash tool hang), it may still be worth filing separately, but please review the above issues first to avoid duplication.

  2. github-actions commented on Jul 29, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions