Skip to content

[Windows Desktop][26.1029] Subagent IAB route disposed before first browser call; subsequent turn cannot recover #59350

Open

Description

@breakingtime126

桌面端 Bug 反馈;经用户明确授权提交,使用 AI 协助整理。

关联但不直接等同:#51105 记录正常完成后的子会话延续不重建路由;本报告额外提供新建子会话首次调用前就释放路由的两组现场时序。与 #58419 共享外层错误,但平台、子会话条件和日志证据不同,尚未确认共同根因。

订阅类型:本次未采集。版本来自安装包标识,未读取 About 对话框。

Bug 反馈:Windows Codex 子智能体的内置浏览器路由在首次调用前被释放

摘要

Windows Codex 客户端会为子智能体创建独立的内置浏览器(IAB)路由,但在部分子会话中,路由在首次浏览器调用前就被释放。子智能体随后执行 cua.getBrowser({ id: "iab" }),返回 Browser is not available: iab。同一子会话开始后续回合后仍然失败。主会话在同一调查期间可以连接 IAB。

已确认故障发生在客户端会话路由层。客户端实现还存在一条可复现的风险路径:通用 idle 通知结束浏览器活动,并删除被标记为临时的子路由,后续 active 不重建路由。现场具体是否由该 idle 分支触发,尚未捕获原始通知或调用栈,因此仍属推断。

环境与影响

项目 观测值
调查日期 2026-11-04
系统版本 API 返回值 Windows 10.0.19045.0,未独立核查完整系统版本标签
客户端安装包 OpenAI.Codex_26.1029.7803.0_x64,Windows Store 包
浏览器后端 release 26.1029.61003
浏览器工具 mcp__cua_repl.js,选择器 iab
使用方式 主会话通过 collaboration.spawn_agent 创建子智能体
用户影响 委派的浏览器验收无法开始;可能被误报为整个应用的内置浏览器不可用

客户端与浏览器后端属于不同组件,两种版本号不一致本身不是版本不兼容的证据。

复现步骤

前置条件:启用 Computer Use,主会话可使用 IAB,并可创建子智能体。无需访问公司内网或业务数据。

  1. 在主会话中执行以下调用。首次使用时遵守工具的初始化要求,将它作为单独的一次工具调用:

    let browser = await cua.getBrowser({ id: "iab" });
  2. 确认主会话连接成功。后续独立调用可用返回的 browser.browserId 列出标签;空标签列表不表示浏览器不可用。

  3. 创建一个诊断子智能体,要求它只进行以下操作,不使用外部浏览器、不读写业务数据:

    先按 CUA 首次调用要求,单独执行:
    let browser = await cua.getBrowser({ id: "iab" });
    若失败,再执行:await cua.listBrowsers();
    报告结果;不要把子会话失败推断为主会话或整个应用失败。
    
  4. 观察子智能体的返回值,同时按子会话 ID 筛选客户端日志中的 IAB_LIFECYCLE 事件。

  5. 向同一个子智能体发起后续诊断回合,沿用 CUA 状态,再次执行 getBrowser 与 listBrowsers。

以上是已发生故障的最小操作路径,尚未在其他设备或其他版本上确认复现率。

预期与实际结果

预期: 子智能体开始浏览器工作时,它自己的 IAB 路由有效。初始化空闲或回合切换不应让之后的合法调用永久失去路由。若产品不支持此类子会话,应提前返回明确的能力限制,而不是先创建后释放路由并返回泛化的不可用错误。

实际: 子路由在首次调用前被释放。新建诊断子会话中,捕获路由约 29 毫秒后即释放,约 15 秒后的首次 getInfo 失败。getBrowser 返回 Browser is not available: iab,浏览器清单仅有已连接的 Edge 扩展,没有 IAB。开始后续回合后仍失败。

日志证据

以下时间为日志原始 UTC;北京时间为 UTC+08:00。会话标识已一致替换为别名,未更改事件顺序、时间戳或错误类型。

样本 A:原始故障

2026-11-04T07:34:10.371Z info [browser-session-registry] IAB_LIFECYCLE captured session route conversationId=CHILD_A disposeAfterSessionActivity=true ownerWebContentsId=1 windowId=1
2026-11-04T07:34:10.375Z info [browser-session-registry] browser_use_iab_backend_startup_ready backend=iab platform=win32 release=26.1029.61003 sessionId=CHILD_A
2026-11-04T07:34:10.393Z info [browser-session-registry] IAB_LIFECYCLE created browser use host conversationId=CHILD_A routeKey=1:CHILD_A windowId=1
2026-11-04T07:34:10.394Z info [browser-session-registry] IAB_LIFECYCLE disposed browser use route conversationId=CHILD_A windowId=1
2026-11-04T07:34:10.394Z info [browser-session-registry] IAB_LIFECYCLE ended browser use session activity conversationId=CHILD_A disposeAfterSessionActivity=true windowId=1
2026-11-04T07:34:26.135Z warning [browser-use-iab-api] IAB_LIFECYCLE iab backend info request failed conversationId=CHILD_A errorMessage="No ChatGPT browser route is available for browser session CHILD_A" errorName=Error

这组日志证明:后端启动完成后,路由仍可能先被释放;startup_ready 不等于首次调用时仍有有效路由。

样本 B:新建诊断子智能体

2026-11-04T07:46:13.943Z info [browser-session-registry] IAB_LIFECYCLE captured session route conversationId=CHILD_B disposeAfterSessionActivity=true ownerWebContentsId=1 windowId=1
2026-11-04T07:46:13.972Z info [browser-session-registry] IAB_LIFECYCLE disposed browser use route conversationId=CHILD_B windowId=1
2026-11-04T07:46:13.972Z info [browser-session-registry] IAB_LIFECYCLE ended browser use session activity conversationId=CHILD_B disposeAfterSessionActivity=true windowId=1
2026-11-04T07:46:28.659Z warning [browser-use-iab-api] IAB_LIFECYCLE iab backend info request failed conversationId=CHILD_B errorMessage="No ChatGPT browser route is available for browser session CHILD_B" errorName=Error

第二轮复测:沿用同一子会话和 CUA 状态,getBrowser 仍返回相同错误,listBrowsers 仍仅有 Edge。该样本未访问业务页面或修改设置。

样本范围与对照

  • 在新建诊断样本之前,检索 2026-11-02 至 2026-11-04 的本地会话,找到 8 个由 CUA 调用实际返回此错误的会话,全部是子智能体。其中 7 个发生于 11 月 4 日;当天有 6 个执行过浏览器清单检查,均仅有 Edge。
  • 新建诊断样本 B 额外复现一次,并在同一子会话的后续回合中再次失败。
  • 主会话在同一调查期间成功连接 IAB、创建标签、导航、读取页面 AX 树并获取截图。该对照并非与每个失败请求严格同时执行。
  • 此样本集合按错误检索得到,没有统计所有成功子会话的分母,不能据此声称“所有子智能体必定失败”。

已确认事实与推断

结论 证据等级与边界
子路由在首次浏览器调用前已经释放 已确认:样本 A、B 的客户端日志与调用记录
连接失败的直接原因是会话无可用路由 已确认:底层错误明确写出 No ChatGPT browser route is available
客户端包含为子智能体建立独立路由的实现 已确认:读取已安装包中的 captureChildSessionRoute
通用 idle 分支可以删除子路由,后续 active 在该监听器中不重建 已确认的代码行为:静态读取及提取函数回放;通知由测试注入
现场由初始化 idle 触发了提前清理 高可信推断:代码路径和时序吻合;缺少原始通知与调用栈,尚不能排除其他 endSessionActivity 调用方
故障属于客户端生命周期缺陷,而非产品预期限制 高度疑似:子路由创建实现、提前清理及恢复缺口支持此判断;尚无官方确认
网络代理、业务页面或登录态导致本次错误 无支持证据:失败发生在会话路由查找层;未完成全面网络排除,不能扩展为所有网络问题均已排除
候选修改已经修复客户端 未确认:仅在提取副本上验证,未安装、未完成真实子会话修复验收

实现定位与原因分析

来源:已安装 app.asar 中的 .vite/build/early-bootstrap-632-62c641245a52ef0e.js。本次仅做读取和本地副本验证。

  1. captureChildSessionRoute(childId, parentId) 从父会话继承窗口信息,但使用子会话自己的 browserConversationId,并设置 disposeAfterSessionActivity=true。
  2. 通用内部通知监听器在 thread/status/changed 且 status.type=idle 时调用 endSessionActivity。该分支没有验证此前是否开始过回合,也没有按回合 ID 或代次过滤过期状态。
  3. endSessionActivity 既释放会话控制权,也在上述标记为 true 时调用 disposeBrowserUseRoute。
  4. 同一个监听器没有处理 active 状态的路由恢复。浏览器连接入口 prepareSessionRoute 在 canServeSession 失败时直接抛错。
  5. 另有子智能体生命周期监听器,在显式 completed、interrupted 和中断开始时调用清理。归档也有独立清理入口。

原 JavaScript 文件 SHA-256:c16675e64dae86bdb09f7720f038a8c2f2beacf0e85bbadd369f407d38662aa4。

建议修复点

优先在客户端会话生命周期层修复,保持子会话独立身份和窗口归属校验。

  1. 将控制权释放与路由销毁拆分。 通用 idle 可释放当前控制权;不要仅凭 idle 就销毁仍可能开始或继续运行的子会话路由。以明确的子会话/回合终态、关闭或归档等事件决定销毁,并检查事件代次。
  2. 明确回合恢复策略。 真正结束后若允许同一子智能体继续运行,应在后续回合开始时重新捕获其合法路由;不要让恢复只能依赖初次 thread/started。缺路由时的重建必须验证父窗口归属,不应借用任意主会话的路由。
  3. 增加清理原因日志。 记录触发通知、状态前后值、回合 ID/代次及清理调用方,让提前释放可以直接归因。
  4. 返回更具体的错误。 区分“后端不可用”“该会话无路由”“窗口已销毁”和“子会话能力不支持”,避免将单一会话故障泛化为整个 IAB 不可用。

本地候选修改仅验证第 1 点的一种实现:给 endSessionActivity 增加 retainSessionRoute 参数,通用 idle 调用传 true,显式生命周期清理沿用销毁行为。它是待评审方案,不是可直接部署的补丁。

已执行验证及限制

对从安装包提取的 captureChildSessionRoute、endSessionActivity 和通知监听器做函数级回放;Electron 窗口、通知源与部分依赖使用替身。

  • 原版:注入“创建子路由 → idle → active”,确认路由被删除且不重建。
  • 候选:同一序列保留原子路由,同时释放控制权。
  • 直接调用显式清理仍删除路由;归档通知仍删除路由;父路由、其他子路由和未知会话处理符合断言。
  • 共 8 项断言通过,候选 JavaScript 语法检查通过。

限制: “显式完成”和“显式中断”两项回放都直接调用同一个清理方法,没有独立覆盖真实完成/中断通知分发。测试不证明真实 Electron 通知顺序正确,也不证明长期路由回收无泄漏。

建议开发侧补充真实端到端用例:初始化 idle 后首次调用;同一子会话第二回合;完成/中断/归档;父窗口关闭;断线重连;并行子会话隔离;过期 idle 通知晚到;重复清理;长时间运行的路由回收。

当前状态与附件

故障仍存在。未修改已安装客户端,未修改安装目录权限或关闭完整性检查,未完成候选修复的真实端到端验收。

可随此报告提交的本地附件:

  • evidence.log:两个现场样本的脱敏日志。
  • replay.cjs、extracted-functions.json:提取函数及回放脚本,执行 node replay.cjs。
  • replay-results.json:回放结果及验证边界。
  • candidate-replacements.json:候选修改的 3 处精确替换。

附件不包含完整客户端代码、公司业务页面截图、业务日志、账户名称、凭据、浏览器配置或完整会话历史。本报告正文通过 GitHub 提交。上述 ZIP 和独立附件未上传;复现步骤、现场日志、原因分析和验证边界均已包含在正文中。

Activity

  1. added
    bug
    app
    windows-os
    subagent
    on Nov 4, 2026
  2. github-actions commented on Nov 4, 2026

    @github-actions
    Contributor

    English translation:

    Desktop bug report; submitted with the user's explicit authorization and organized with AI assistance.

    Related, but not directly equivalent: #51105 documents continuation of a child session after normal completion without rebuilding its route; this report additionally provides two sets of observed event timings in which routes were disposed before the first call in newly created child sessions. It shares the outer error with #58419, but the platform, child-session conditions, and log evidence differ. A common root cause has not been confirmed.

    Subscription type: not collected this time. The version comes from the installation package identifier; the About dialog was not read.

    Bug report: Windows Codex subagent's built-in browser route is disposed before the first call

    Summary

    The Windows Codex client creates separate built-in browser (IAB) routes for subagents, but in some child sessions, the route is disposed before the first browser call. When the subagent subsequently executes cua.getBrowser({ id: "iab" }), it returns Browser is not available: iab. It continues to fail when the same child session starts a subsequent turn. The main session could connect to IAB during the same investigation.

    The failure has been confirmed to occur at the client's session-routing layer. The client implementation also contains a reproducible risk path: a generic idle notification ends browser activity and deletes child routes marked as temporary, and a subsequent active does not rebuild the route. Whether this particular incident was triggered by that idle branch remains an inference, because the original notification or call stack has not been captured.

    Environment and impact

    Item Observed value
    Investigation date 2026-11-04
    Value returned by the system version API Windows 10.0.19045.0; the full system version label was not independently verified
    Client installation package OpenAI.Codex_26.1029.7803.0_x64, Windows Store package
    Browser backend release 26.1029.61003
    Browser tool mcp__cua_repl.js, selector iab
    Usage The main session creates subagents through collaboration.spawn_agent
    User impact Delegated browser acceptance testing cannot begin; this may be misreported as the built-in browser being unavailable throughout the application

    The client and browser backend are different components. Their differing version numbers are not, by themselves, evidence of version incompatibility.

    Steps to reproduce

    Prerequisites: Computer Use is enabled, the main session can use IAB, and subagents can be created. No access to a company intranet or business data is required.

    1. Execute the following call in the main session. On first use, follow the tool's initialization requirements and make this a separate tool call:

      let browser = await cua.getBrowser({ id: "iab" });
    2. Confirm that the main session connects successfully. A subsequent separate call can use the returned browser.browserId to list tabs; an empty tab list does not mean the browser is unavailable.

    3. Create a diagnostic subagent and ask it to perform only the following operations, without using an external browser or reading or writing business data:

      First, following the CUA first-call requirements, execute separately:
      let browser = await cua.getBrowser({ id: "iab" });
      If it fails, then execute: await cua.listBrowsers();
      Report the results; do not infer from a child-session failure that the main session or the entire application has failed.
      
    4. Observe the subagent's return values while filtering IAB_LIFECYCLE events in the client logs by the child-session ID.

    5. Start a subsequent diagnostic turn with the same subagent, retain the CUA state, and execute getBrowser and listBrowsers again.

    The above is the minimal sequence of operations in which the failure has occurred. The reproduction rate has not yet been confirmed on other devices or versions.

    Expected and actual results

    Expected: When a subagent begins browser work, its own IAB route is valid. Initialization idle states or turn transitions should not permanently deprive subsequent valid calls of their route. If the product does not support this type of child session, it should return a clear capability limitation upfront, instead of creating and then disposing the route and returning a generic unavailable error.

    Actual: The child route is disposed before the first call. In a newly created diagnostic child session, the route was disposed approximately 29 milliseconds after capture, and the first getInfo approximately 15 seconds later failed. getBrowser returns Browser is not available: iab, and the browser list contains only the connected Edge extension, with no IAB. It continues to fail after a subsequent turn starts.

    Log evidence

    The times below are the original UTC timestamps from the logs; Beijing time is UTC+08:00. Session identifiers have been consistently replaced with aliases. Event order, timestamps, and error types have not been changed.

    Sample A: Original failure

    2026-11-04T07:34:10.371Z info [browser-session-registry] IAB_LIFECYCLE captured session route conversationId=CHILD_A disposeAfterSessionActivity=true ownerWebContentsId=1 windowId=1
    2026-11-04T07:34:10.375Z info [browser-session-registry] browser_use_iab_backend_startup_ready backend=iab platform=win32 release=26.1029.61003 sessionId=CHILD_A
    2026-11-04T07:34:10.393Z info [browser-session-registry] IAB_LIFECYCLE created browser use host conversationId=CHILD_A routeKey=1:CHILD_A windowId=1
    2026-11-04T07:34:10.394Z info [browser-session-registry] IAB_LIFECYCLE disposed browser use route conversationId=CHILD_A windowId=1
    2026-11-04T07:34:10.394Z info [browser-session-registry] IAB_LIFECYCLE ended browser use session activity conversationId=CHILD_A disposeAfterSessionActivity=true windowId=1
    2026-11-04T07:34:26.135Z warning [browser-use-iab-api] IAB_LIFECYCLE iab backend info request failed conversationId=CHILD_A errorMessage="No ChatGPT browser route is available for browser session CHILD_A" errorName=Error
    

    These logs demonstrate that even after backend startup completes, the route can still be disposed before use; startup_ready does not mean a valid route remains available at the time of the first call.

    Sample B: Newly created diagnostic subagent

    2026-11-04T07:46:13.943Z info [browser-session-registry] IAB_LIFECYCLE captured session route conversationId=CHILD_B disposeAfterSessionActivity=true ownerWebContentsId=1 windowId=1
    2026-11-04T07:46:13.972Z info [browser-session-registry] IAB_LIFECYCLE disposed browser use route conversationId=CHILD_B windowId=1
    2026-11-04T07:46:13.972Z info [browser-session-registry] IAB_LIFECYCLE ended browser use session activity conversationId=CHILD_B disposeAfterSessionActivity=true windowId=1
    2026-11-04T07:46:28.659Z warning [browser-use-iab-api] IAB_LIFECYCLE iab backend info request failed conversationId=CHILD_B errorMessage="No ChatGPT browser route is available for browser session CHILD_B" errorName=Error
    

    Second test turn: using the same child session and CUA state, getBrowser still returned the same error, and listBrowsers still contained only Edge. This sample did not access business pages or change settings.

    Sample scope and control

    • Before creating the new diagnostic sample, a search of local sessions from 2026-11-02 through 2026-11-04 found 8 sessions in which CUA calls actually returned this error, all of them subagents. Of these, 7 occurred on November 4; 6 of that day's sessions performed a browser-list check, and all listed only Edge.
    • The newly created diagnostic sample B reproduced the failure once more, and failed again in a subsequent turn of the same child session.
    • During the same investigation, the main session successfully connected to IAB, created a tab, navigated, read the page's AX tree, and captured a screenshot. This control was not performed at precisely the same time as each failed request.
    • This sample set was obtained by searching for the error. The denominator of all successful child sessions was not counted, so it cannot support a claim that “all subagents always fail.”

    Confirmed facts and inferences

    Conclusion Evidence level and limitations
    The child route had already been disposed before the first browser call Confirmed: client logs and call records for samples A and B
    The direct cause of the connection failure is the absence of an available route for the session Confirmed: the underlying error explicitly states No ChatGPT browser route is available
    The client includes an implementation that establishes separate routes for subagents Confirmed: inspection of captureChildSessionRoute in the installed package
    The generic idle branch can delete a child route, and a subsequent active does not rebuild it in that listener Confirmed code behavior: static inspection and replay of extracted functions; notifications were injected by the test
    An initialization idle triggered premature cleanup in the observed incident High-confidence inference: the code path and timing match; without the original notification and call stack, other callers of endSessionActivity cannot yet be ruled out
    The failure is a client lifecycle defect rather than an intended product limitation Strongly suspected: supported by the child-route creation implementation, premature cleanup, and the recovery gap; no official confirmation yet
    A network proxy, business page, or login state caused this error No supporting evidence: the failure occurs at the session-route lookup layer; a comprehensive network investigation has not been completed, so this cannot be extended to claim that all network issues have been ruled out
    The candidate change has fixed the client Unconfirmed: verified only on an extracted copy; not installed, and acceptance testing of the fix in a real child session has not been completed

    Implementation location and cause analysis

    Source: .vite/build/early-bootstrap-632-62c641245a52ef0e.js in the installed app.asar. This investigation involved only reading it and testing a local copy.

    1. captureChildSessionRoute(childId, parentId) inherits window information from the parent session, but uses the child session's own browserConversationId and sets disposeAfterSessionActivity=true.
    2. The generic internal notification listener calls endSessionActivity on thread/status/changed when status.type=idle. This branch neither checks whether a turn has previously started nor filters stale states by turn ID or generation.
    3. endSessionActivity both releases session control and calls disposeBrowserUseRoute when the flag above is true.
    4. The same listener does not handle route restoration for the active state. The browser connection entry point, prepareSessionRoute, throws an error immediately when canServeSession fails.
    5. There is also a subagent lifecycle listener that invokes cleanup on explicit completed and interrupted states, and when interruption begins. Archiving has a separate cleanup entry point as well.

    Original JavaScript file SHA-256: c16675e64dae86bdb09f7720f038a8c2f2beacf0e85bbadd369f407d38662aa4.

    Suggested fixes

    Prioritize a fix at the client session-lifecycle layer, preserving independent child-session identities and window ownership validation.

    1. Separate releasing control from destroying the route. A generic idle state may release current control; idle alone should not destroy the route of a child session that may still start or continue running. Determine destruction based on events such as explicit terminal child-session/turn states, closure, or archiving, and check the event generation.
    2. Define a clear turn-resumption strategy. If the same subagent is allowed to continue after actually finishing, recapture its valid route when a subsequent turn begins; recovery should not depend solely on the initial thread/started. Rebuilding a missing route must validate parent-window ownership and must not borrow an arbitrary main session's route.
    3. Add cleanup-reason logging. Record the triggering notification, previous and next state values, turn ID/generation, and cleanup caller so that premature disposal can be directly attributed.
    4. Return more specific errors. Distinguish “backend unavailable,” “no route for this session,” “window destroyed,” and “child-session capability unsupported,” to avoid generalizing a single-session failure into IAB being unavailable throughout the application.

    The local candidate change tested only one implementation of item 1: add a retainSessionRoute parameter to endSessionActivity, pass true from generic idle calls, and retain destruction behavior for explicit lifecycle cleanup. This is a proposal awaiting review, not a patch ready for direct deployment.

    Validation performed and limitations

    Function-level replay was performed on captureChildSessionRoute, endSessionActivity, and the notification listener extracted from the installation package; test doubles were used for Electron windows, notification sources, and some dependencies.

    • Original version: injected “create child route → idle → active” and confirmed that the route was deleted and not rebuilt.
    • Candidate: the same sequence retained the original child route while releasing control.
    • Direct invocation of explicit cleanup still deleted the route; archive notifications still deleted the route; handling of the parent route, other child routes, and unknown sessions met the assertions.
    • All 8 assertions passed, and the candidate JavaScript passed syntax checking.

    Limitations: The “explicit completion” and “explicit interruption” replays both directly called the same cleanup method, without independently covering real completion/interruption notification dispatch. The tests do not prove that real Electron notifications occur in the correct order, nor do they prove that long-term route reclamation is leak-free.

    Suggested additional real end-to-end cases for developers: first call after initialization idle; second turn in the same child session; completion/interruption/archiving; parent-window closure; reconnection after disconnection; isolation of parallel child sessions; late arrival of stale idle notifications; repeated cleanup; and route reclamation during long-running operation.

    Current status and attachments

    The failure persists. The installed client has not been modified, installation-directory permissions have not been changed, integrity checks have not been disabled, and real end-to-end acceptance testing of the candidate fix has not been completed.

    Local attachments available for submission with this report:

    • evidence.log: sanitized logs for the two observed samples.
    • replay.cjs, extracted-functions.json: extracted functions and replay script; run node replay.cjs.
    • replay-results.json: replay results and validation limitations.
    • candidate-replacements.json: 3 exact replacements for the candidate change.

    The attachments do not contain complete client code, screenshots of company business pages, business logs, account names, credentials, browser profiles, or complete session histories. The body of this report is submitted through GitHub. The ZIP and individual attachments mentioned above have not been uploaded; the reproduction steps, observed logs, cause analysis, and validation limitations are all included in the body.

  3. yifei-ambr commented on Nov 24, 2026

    @yifei-ambr

    macOS confirms the fresh-child failure. On desktop 26.1117.41037 (build 29803), the child's in-app browser route was ready at +2 ms and disposed at +7 ms. Its first browser call at ~10 s returned Browser is not available: iab. The parent opened the same URL. The same child failed again on its next turn.

    Reproduce in a local desktop chat

    1. Ask a new subagent to open https://developers.openai.com/codex/app/browser with its own hidden in-app browser and report the title.
    2. Open the same link from the parent as a control.
    3. Resume the original child and ask it to open about:blank in its own in-app browser.

    Triage request. Could the desktop Browser/Subagents owner confirm the tracking issue or name a build to retest? A passing build lets the same child open its own tab on both turns, and ending one child leaves a sibling in the same window usable.

    Why initial idle matters, and where to look

    The child route was captured with disposeAfterSessionActivity=true. At its first getInfo, the desktop log reported IAB browser belongs to another task. An independent run of the bundled app-server (0.171.0-alpha.13) emitted idle → active → turn/started at startup and idle → turn/completed at finish. Replaying initial idle against the installed desktop listener calls endSessionActivity and removes the provisional route in the fixture. The historical log records disposal without identifying the caller.

    A candidate fix would capture the child's validated route on every authoritative turn start and clean up on a matching terminal event. Keep ownership checks, interruption and archive cleanup. For asynchronous disposal, tie cleanup to the exact route instance so it cannot remove a replacement. Static inspection of 26.1120.41243 (build 30607) found the same idle branch; runtime behavior on that build remains unverified.

    Optional regression fixture · Node.js · no dependencies

    Save the block as child-browser-lifecycle.test.cjs and run node --test child-browser-lifecycle.test.cjs. The startup assertion failed against the installed listener and passed against this synchronous reference policy. All six tests passed. Mutation checks caught eager idle cleanup, skipped recapture, stale starts and completions, omitted archive cleanup, lost capture retries, and window-wide teardown. The desktop acceptance check above covers real browser behavior.

    // Run: node --test child-browser-lifecycle.test.cjs (Node 18+).
    // Synchronous reference policy for child routes only. The desktop owner supplies
    // authoritative child/turn identity, idempotent capture, and window validation.
    'use strict';
    const test = require('node:test');
    const assert = require('node:assert/strict');
    
    function candidateListener(registry, currentTurn) {
      const attachedTurn = new Map();
      return ({ method, params }) => {
        const child = params.threadId;
        if (method === 'thread/archived') {
          registry.disposeConversation(child);
          attachedTurn.delete(child);
          return;
        }
        if (method === 'turn/started') {
          const turn = params.turn.id;
          if (currentTurn(child) !== turn || attachedTurn.get(child) === turn) return;
          registry.captureOwnedRoute(child);
          attachedTurn.set(child, turn);
        }
        if (method === 'turn/completed' && attachedTurn.get(child) === params.turn.id) {
          registry.endSessionActivity({ conversationId: child });
          attachedTurn.delete(child);
        }
      };
    }
    
    // Both initial idle and real completion arrive through the listener under test.
    function fixture(makeListener = candidateListener) {
      const owners = new Map([['a', 'window-a'], ['b', 'window-b']]);
      const routes = new Map();
      const runtime = new Map();
      const calls = [];
      const registry = {
        captureOwnedRoute(child) {
          const owner = owners.get(child);
          if (!owner) throw Error('Missing validated owner');
          routes.set(child, owner);
          calls.push(['capture', child]);
        },
        endSessionActivity({ conversationId }) {
          routes.delete(conversationId);
          calls.push(['release', conversationId]);
        },
        disposeConversation(child) {
          routes.delete(child);
          owners.delete(child);
          calls.push(['archive', child]);
        }
      };
      const notify = makeListener(registry, child => runtime.get(child));
      const status = (child, type) =>
        notify({ method: 'thread/status/changed', params: { threadId: child, status: { type } } });
      function turn(method, child, id, status) {
        if (method === 'turn/completed' && runtime.get(child) === id) runtime.delete(child);
        notify({ method, params: { threadId: child, turn: { id, status } } });
      }
      function start(child, id) {
        runtime.set(child, id);
        turn('turn/started', child, id, 'inProgress');
      }
      return { registry, owners, routes, calls, notify, status, turn, start };
    }
    
    // This check can also receive an adapter around the shipping desktop listener.
    function assertStartup(makeListener) {
      const f = fixture(makeListener);
      f.registry.captureOwnedRoute('a');
      f.status('a', 'idle');
      assert.equal(f.routes.get('a'), 'window-a', 'initial idle released the child route');
      f.status('a', 'active');
      f.start('a', 'first');
      assert.equal(f.routes.get('a'), 'window-a', 'first turn has no owned route');
    }
    
    module.exports = { assertStartup };
    if (require.main === module) {
      test('startup tolerates idle before active and turn/started', () => assertStartup(candidateListener));
    
      test('only the matching terminal event releases a route, exactly once', () => {
        const f = fixture();
        f.start('a', 'first');
        f.status('a', 'idle');
        assert.equal(f.routes.get('a'), 'window-a');
        f.turn('turn/completed', 'a', 'first', 'completed');
        f.turn('turn/completed', 'a', 'first', 'completed');
        f.turn('turn/started', 'a', 'first', 'inProgress');
        assert.deepEqual(f.calls, [['capture', 'a'], ['release', 'a']]);
        assert.equal(f.routes.size, 0);
      });
    
      test('continuation recaptures once, tolerating stale start and completion', () => {
        const f = fixture();
        f.start('a', 'first');
        f.turn('turn/completed', 'a', 'first', 'completed');
        f.start('a', 'second');
        f.turn('turn/started', 'a', 'second', 'inProgress');
        f.turn('turn/started', 'a', 'first', 'inProgress');
        f.turn('turn/completed', 'a', 'first', 'completed');
        assert.deepEqual(f.calls, [['capture', 'a'], ['release', 'a'], ['capture', 'a']]);
        assert.equal(f.routes.get('a'), 'window-a');
        f.turn('turn/completed', 'a', 'second', 'completed');
        assert.equal(f.routes.size, 0);
      });
    
      test('children sharing a parent window release their routes independently', () => {
        const f = fixture();
        f.owners.set('b', 'window-a');
        f.start('a', 'a1');
        f.start('b', 'b1');
        assert.deepEqual([...f.routes], [['a', 'window-a'], ['b', 'window-a']]);
        f.turn('turn/completed', 'a', 'a1', 'interrupted');
        assert.deepEqual([...f.routes], [['b', 'window-a']]);
        f.turn('turn/completed', 'b', 'b1', 'failed');
        assert.equal(f.routes.size, 0);
      });
    
      test('archive releases a provisional route; missing owner cannot borrow a sibling', () => {
        const f = fixture();
        f.registry.captureOwnedRoute('a');
        f.start('b', 'b1');
        f.notify({ method: 'thread/archived', params: { threadId: 'a' } });
        assert.throws(() => f.start('a', 'late'), /Missing validated owner/);
        assert.deepEqual([...f.routes], [['b', 'window-b']]);
        assert.deepEqual(f.calls, [['capture', 'a'], ['capture', 'b'], ['archive', 'a']]);
      });
    
      test('failed capture leaves the same turn retryable when its own window becomes ready', () => {
        const f = fixture();
        f.owners.delete('a');
        assert.throws(() => f.start('a', 'first'), /Missing validated owner/);
        f.owners.set('a', 'window-a');
        f.start('a', 'first');
        assert.deepEqual([...f.routes], [['a', 'window-a']]);
        assert.deepEqual(f.calls, [['capture', 'a']]);
      });
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbrowserbugsubagentwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions