Skip to content

A follow-up message to a delegated thread locks it out of the preview tab it opened #42209

Backlog

Description

@santissimoo

What happened

An agent thread opens a preview tab and finishes its turn. I send that same thread one more message. From then on the thread can't use or close its own tab. Every action comes back as "This browser tab belongs to another agent session or a human. Open your own tab."

It takes about ten seconds to hit and needs no idle wait. My agents lose whatever state they had in the page, open a second tab and leave the first one behind because nothing can close it. Yesterday that was 18 rejected calls across 10 agent sessions on my machine, and 19 across 17 the day before.

Diagnosis

  • The tab owner is the provider session, not the thread. hostAssignmentKey in apps/server/src/mcp/PreviewAutomationBroker.ts joins the environment id, the provider session id and the thread id, and that string is sent as agentSessionId.
  • SessionControl.agentMayAct in apps/server/src/preview/SessionControl.ts only accepts an exact match. ServerBrowser.ts then rejects every operation that isn't a read with agentMismatch.
  • The provider session doesn't outlive the turn. In server.trace.ndjson, McpSessionRegistry.revokeProviderSession runs 2 s after the child's turn ends, and McpSessionRegistry.revokeThread runs when the next message arrives. The next turn gets a new provider session id, so the key no longer matches. I read that order from the trace. I didn't trace the revoke call sites in source.
  • So this doesn't need the 30 minute idle stop from [Bug]: Resumed Bob thread cannot navigate or close its own preview tab after the 30-minute idle stop #23021. A turn boundary is enough.
  • preview_status still works and shows the change: ownedByCaller is true in the preview_open result and false one message later, with owner: "agent" and generation: 0 unchanged.
  • The owner key is the same on main at 13b7893.

I tested a delegated child thread. I haven't tested a top-level thread.

Steps to reproduce

  1. Run the desktop app with its local server.
  2. From an agent thread, call delegate_task with a task that calls preview_open({ url: "https://example.com/?owner-repro=1", open: false, reuseExistingTab: false }), then preview_evaluate("navigator.userAgent"), then ends its turn. Both calls succeed.
  3. When the child finishes, call t3_thread_send on the child thread and ask it to run preview_evaluate("location.href"), preview_navigate to https://example.com/?owner-repro=2 and preview_status on the same tab.
  4. Evaluate and navigate are rejected. Status shows ownedByCaller: false and the URL is still ?owner-repro=1.
  5. Send one more message asking for t3_preview_close on that tab. It is rejected with agentMismatch.

Seen 1 of 1 in this controlled run. I also saw it 3 of 3 the night before on 0.1.12-nightly.20261123.5151, when a parent thread interrupted three children and messaged them to carry on.

Version

0.1.12-nightly.20261123.5165

Environment

macOS 27.2.1 arm64, desktop app with local server, Claude Code agents (claude-opus-5-5), Electron 44.10.1

Evidence

# tool results in the child thread, same tab, 2026-11-24 UTC
14:30:30 preview_open      "control":{"owner":"agent","ownedByCaller":true,"generation":0}
14:30:32 preview_evaluate  T3CodeNightly/0.1.12-nightly.20261123.5165 Chrome/152.0.7977.169 Electron/44.10.1
# turn ends, follow-up message arrives
14:30:42 preview_evaluate  This browser tab belongs to another agent session or a human. Open your own tab.
14:30:44 preview_navigate  This browser tab belongs to another agent session or a human. Open your own tab.
14:30:45 preview_status    "url":"https://example.com/?owner-repro=1","control":{"owner":"agent","ownedByCaller":false,"generation":0}
# second follow-up message
14:30:58 t3_preview_close  {"_tag":"PreviewAutomationControlInterruptedError","operation":"close","clientId":"server-browser","requestId":"preview-1250","cause":{"message":"This tab belongs to another agent session. You can read it, but open your own tab to act.","detail":"agentMismatch"},"reason":"agentMismatch"}

# server.trace.ndjson
14:30:30.171 mcp.tool.preview_open 508ms
14:30:32.293 mcp.tool.preview_evaluate 4.7ms
14:30:34.483 orchestrationV2.EventSink.writeIfRunCurrent   (last event write before the gap)
14:30:36.285 McpSessionRegistry.revokeProviderSession
14:30:38.554 orchestrationV2.dispatch.once                 (follow-up message)
14:30:38.607 McpSessionRegistry.revokeThread
14:30:42.761 mcp.tool.preview_evaluate 2.7ms   exit Success, tool result is the rejection
14:30:44.091 mcp.tool.preview_navigate 2.5ms   exit Success, tool result is the rejection

Related issues

#23021 is the same rejection after Bob's idle stop. It was closed as not planned with a request for exact steps and a version, which are above, on Claude and with no idle wait. #26878 (open PR) lets a later session close the tab but keeps navigate, click and evaluate refused. #26864 (open) is the orphaned tab nobody can close.

Fix applied or workaround

Nothing was changed on the machine. Agents open a new tab after every follow-up message. The old tab stays open until the idle sweep.

Filed by

Claude Code (claude-fable-5-2), triage playbook followed by hand

Activity

  1. added
    via-triage
    on Nov 24, 2026
  2. SimonLiu423 commented on Nov 27, 2026

    @SimonLiu423
    Contributor

    This also happens on a top-level thread, with no delegation and no follow-up from a parent. The trigger is the Claude provider's 2-minute idle stop (DEFAULT_IDLE_TIMEOUT_MS in ProviderSessionManager.ts). When the session is released, its MCP credential is revoked. The next turn then gets a new one, with a new UUID in the owner key.

    In one thread on 0.1.14-nightly.20261127.5319 (desktop app with its local server, macOS arm64, claude-opus-5-5), every reply sent more than 2 minutes after the agent's last turn lost the tab: after 2m10s, about 4m and 2m48s. Replies under 2 minutes kept it. The provider event log shows query.close exactly 2:00 after a turn ended.

    This makes human-in-the-loop flows fail almost every time. The user logs in to a site in the tab, and with a CAPTCHA and OTP that takes more than 2 minutes, so the agent can't use the logged-in tab afterwards. Opening a second tab then logged the user out of a site that allows only one session. The "or a human" in the error also misled both the user and the agent into thinking a human had taken control of the tab.

    #42219 keys ownership on the thread, so it should cover this case too.

    Produced by Claude Code (claude-opus-5-5) following the T3 Code triage playbook.

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

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions