Skip to content
Source
Sign inSign up
pingdotgg/t3code

Agent browser tabs are rarely closed: the close tool isn't in the instructions, and streamed tabs never idle-close #18231

ClosedLuzivog(GitHub profile, opens in a new tab) opened this issue 1 comment

Area

apps/server (preview), provider instructions

What happens

Agents leave the browser tabs they open behind after they're done. On one machine over a week: 78 agent tabs opened, 46 closed by the agent (every one with t3_preview_close), 32 left open, together at least 167 tab-hours after their last use. Agents that do close, close right away. Agents that don't, end their turn a median 30 s after their last browser call, and the tab outlives the turn.

Why

Nothing owns the end of an agent tab's life:

  • T3's built-in browser instructions (T3_CODE_BROWSER_TOOL_INSTRUCTIONS) and preview_open's description never mention closing. The close tool sits outside the preview_* family as t3_preview_close, and the only place that points to it is the tab-limit error.
  • closeIdleAgentTabs only closes agent tabs with viewers.size === 0. A tab streamed in the panel has a viewer, so a tab left on screen never closes, even when nobody touches it. Desktop-hosted tabs had no viewers, so this only shows once tabs stream (remote environments, #17316's desktop fallback, etc.).
  • markUsed refreshes every one of an agent's tabs in a thread on any browser call, so tabs it abandoned stay alive while it keeps using another one.
  • Nothing runs when a turn ends or a thread settles. Deleting the thread (preview.cleanup) or restarting the app closes them.

Suggestions

  1. Name t3_preview_close in the built-in browser instructions ("close the tabs you opened when you're done, unless the user needs to act in one"), or add a preview_close alias next to preview_open (#8886 asked for the tool; it exists now but agents don't find it).
  2. Let closeIdleAgentTabs close an agent tab that only has passive viewers: no viewer input (inputAt) and no agent call on that tab for the idle window, so a tab the user is actively using stays.
  3. Track usedAt per tab instead of refreshing all of the agent's tabs in the thread.

Related: #17180 (an agent tab nobody looks at holding a wake lock).

  1. Note

    Grok responding on behalf of Julius.

    Intended behavior. closeIdleAgentTabs only closes agent tabs with viewers.size === 0 after 30 minutes without an agent request — a streamed panel tab has a viewer, so it stays open. Open PR #18147 goes further the same way (skip desktop-rendered tabs entirely). markUsed refreshing every tab that agent owns on the thread is deliberate (docstring: any request keeps those tabs from idling out).

    t3_preview_close already exists (#8887 / #2829); agents that call it close immediately in your data. Naming it in T3_CODE_BROWSER_TOOL_INSTRUCTIONS, a preview_close alias, per-tab usedAt, or idle-closing passive-viewer tabs are product changes — please file an Ideas discussion. Related wake-lock leftover: #17180.

  2. juliusmarminge added labelswontfix

  3. juliusmarminge added labelsvia-triage

  4. juliusmarminge closed this

Sign in to join this conversation.