browser-harness
browser-harness copied to clipboard
feat: tab ownership/protection for shared agent Chrome instance (agents close each other's tabs)
问题描述
BU_NAME=agent 的 Agent Chrome (9223) 是多 agent 共享实例(researchbot、devkeeper 等多个 Hermes agent 会同时用浏览器)。当前 browser-harness 没有任何「标签页归属/保护」机制,导致一个 agent 做清理动作(关闭自己调研产生的标签页)时会误关其他 agent 正在使用的工作标签。
2026-08-05 实测事故:
- researchbot 跑完一次 ChatGPT Deep Research 冒烟测试后执行清理(关闭本次调研产生的 chatgpt 标签)
- 脚本用
list_tabs()枚举 → 过滤'chatgpt.com' in url and not in protect_list→close_tab()批量关闭 - 结果误关了 3 个不是本次调研、属于其他 agent 工作的会话标签:
GEO研究与AI引擎分析(chatgpt.com/c/6a7305c9-…)English New Lesson — 2026-08-05(chatgpt.com/c/6a729d9e-…)Issue #8 Fix Verification(chatgpt.com/c/6a732666-…)
- 会话数据在服务端保留(URL 可恢复),所以无数据丢失,但会打断其他 agent 的工作流(它们靠「当前打开的标签页 + 屏幕截图」判断状态,标签没了会误判任务状态)
期望能力(按价值排序)
- 标签页锁定/保护:
close_tab()前支持设置保护标记,或提供protect_tab(targetId)/lock_tabs()API;被保护的标签默认拒绝 close(除非显式force=True)。最实用的是按会话 URL 或 tab 创建者保护。 - 标签页归属标注:
list_tabs()返回每个 tab 的「创建者/用途」字段(或至少提供tab_owner(targetId)辅助),让清理脚本能区分「我的标签」vs「别人的标签」。 - 文档/惯例:在 SKILL.md / install.md 明确共享实例下关闭标签的安全惯例(例如:只关闭你自己
new_tab()返回 targetId 打开的标签,不按域名批量关闭)。
当前缓解(不依赖修复即可用)
- 清理时用
new_tab()返回的 targetId 白名单,而不是「URL 包含 chatgpt.com」批量过滤; - 每次 agent 会话记录自己打开的 tab targetId,只关这些。
环境
- browser-harness 0.1.8 (git)
- macOS 15.7,Agent Chrome 9223,BU_NAME=agent(多 agent 共享)
duplicate of #375
PR #616 gives each named daemon its own dedicated tab (created via Target.createTarget, closed on shutdown), which removes the attach-first-page fights described here. Tab ownership/protection against other agents closing your tab is still open, but with per-name tabs the common clobber path is gone.