Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Preview automation fails for every agent-created thread — composite runtime tab id exceeds the 128-char PreviewTabId cap #7720

Closedastarktc(GitHub profile, opens in a new tab) opened this issue 0 comments

Before submitting

  • I searched existing issues and did not find an exact duplicate (#6355, #3713, #3715 describe different failure paths — detach-on-navigation and snapshot timeouts; this one is a deterministic schema-validation failure keyed to thread-id length).
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop / apps/web / packages/contracts (preview automation path)

Summary

Preview automation (preview_* MCP tools) fails for every agent-created thread — delegated-task children and MCP/t3_thread_start-created threads — while working normally in operator-opened UI threads. Root cause: the web client's composite runtime tab id exceeds the 128-char PreviewTabId schema cap whenever the owning thread id is long, and all agent-created thread ids are long.

Notably, the failures are not no-ops: preview_open/navigation side effects still land (tabs visibly open and load in the desktop UI) while the agent receives only an opaque error — so agents perform blind writes against a browser they can never observe or address again.

Steps to reproduce

  1. Start any agent thread that is not an operator-opened UI thread — e.g. have an agent call delegate_task, or create a thread via the MCP surface / t3_thread_start.
  2. From that thread, call any preview automation tool, e.g. preview_open {url:"https://example.com"}.
  3. Observe: the tab may actually open in the desktop UI, but the tool call returns Preview automation <op> failed on client preview-<id> (some ops instead hang for the full 15 s timeout: Preview automation press timed out after 15000ms.).
  4. Repeat the same call from a thread the operator opened in the UI: it succeeds.

Observed on macOS, desktop app built from source (state dir ~/.t3/userdata). We hit it on a fork build (main + PR #7211's Pi provider), but every implicated line is upstream main — verified against upstream/main before filing.

Diagnosis

  • The web client builds a composite runtime tab id: JSON.stringify([environmentId, threadId, serverEpoch, tabId]) (apps/web/src/browser/previewRuntimeTabId.ts).
  • That id crosses the desktop IPC bridge, where the contract caps tab ids at 128 chars: export const PreviewTabId = TrimmedNonEmptyString.check(Schema.isMaxLength(128)); (packages/contracts/src/preview.ts:24).
  • desktop.trace.ndjson shows the failure directly: SchemaError: Expected a value with a length of at most 128 at ["tabId"] on channel desktop:preview-automation-status; every automation op then surfaces as PreviewAutomationExecutionError.
  • Thread-id lengths measured from state.sqlite: operator/UI threads are 36-char UUIDs (composite ≈ 91–120 chars → fits); thread:mcp:* ≈ 86 chars, provider-native ≈ 72–125, thread:delegated-task:* ≈ 129 — all composites > 128 → 100% failure for agent-created threads. Empirically confirmed both ways in one environment on the same build: 0/6 automation tasks completable from two agent-created threads; full success (open + evaluate) from an operator-opened thread.

Suggested fixes

  1. Make the composite runtime tab id length-safe — e.g. hash the composite (the id only needs uniqueness + stability), or raise/remove the 128-char cap on the IPC path so it accommodates the longest generated thread ids.
  2. Independently worth doing: surface the remote diagnostic in the MCP error text (the contract already carries structured remote error info but strips it to remoteMessageLength before it reaches the agent) — Preview automation <op> failed on client <id> is indistinguishable from "desktop app closed", and the schema cause was only findable by reading ~/.t3/userdata/logs/*.ndjson plus source. A bad locator and a dead browser currently produce the same one-liner.

Sign in to join this conversation.