Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(clients): native subagent threads show status instead of a composer #13624

Mergedjuliusmarmingemerged 8 commits intot3code/codex-turn-mapping fromrefs/pull/13624/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Stacked on #13614 (base v2/subagent-working-state).

A native subagent's child thread (one the provider spawned on its own, for example Claude's Agent tool) showed the full composer with model/effort/access pickers, but you can't actually message that subagent. Sending anyway did something surprising on every provider:

  • Claude and Cursor started a new provider session with none of the subagent's context, because the child has activeProviderThreadId: null.
  • Codex and OpenCode resumed the child's native thread while the parent still owned it.
  • Grok switched the single ACP runtime to the child session, which puts the parent at risk.

What changed

  • Contracts: added isProviderNativeSubagentThread(thread), which checks lineage.relationshipToParent === "subagent" && creationSource === "provider". delegate_task children are creationSource: "mcp" and don't match.
  • Server: the message.dispatch command to such a thread fails with a typed OrchestratorSubagentThreadReadOnlyError before any event is written. The check sits on the command branch, not inside dispatchMessage, because the async question-answer path (runtime-request.respond with a message-mode question, which Codex subagents write to their own child thread) reuses dispatchMessage and must still land. The error message is "This subagent is run by its provider and cannot take messages. Message the parent thread instead." userFacingDispatchErrorMessage picks it up, so it lands in the web toast and the mobile outbox restore through the existing OrchestrationV2DispatchCommandError.detail path. ThreadMessageIntake treats it as not accepted, so any claimed attachments are released.
  • client-runtime: deriveProviderSubagentStatus(projection) gets status, start, and end times from the child's runless root turn (null until it arrives). formatProviderSubagentStatus produces the text: "Starting", "Working 1m 5s", "Completed in 34s", "Cancelled". formatModelSelectionEffort(selection, models) reads the effort from the thread's own model selection (native children inherit the parent's options; a subagent on a different model reports none, so nothing shows) over the ids reasoningEffort/effort/reasoning/variant, and names it with the provider catalog's option label ("Extra High"), else capitalizes the raw value. Web and mobile include the effort in the accessible label. deriveRunlessWorkStartedAt (from #13614) is now gated on the same predicate. Both read data the child projection already has, so there's no extra websocket payload.
  • Web: ChatView renders ProviderSubagentBar inside the existing ComposerSurface.Host ([provider icon] model · effort (muted) · status · "Runs on its own" · ghost "Open parent" button; the icon is the composer picker's ProviderInstanceIcon at size-4, the model name is the picker's display name) whenever the thread is provider-native, and hides the context/model strips. The live timer updates the DOM directly, with no re-render per tick, and is aria-hidden; a visually hidden role="status" region announces only transitions ("Working", "Completed"). While the child has a pending approval or question, the composer that renders those appears below the bar with a new hideThreadSettings prop, which drops the model/effort/access pickers and attachments.
  • Mobile: ThreadDetailScreen renders the same bar in place of ThreadComposer whenever the thread is provider-native, with the composer's ProviderIcon (16px), the model name, the effort in text-foreground-secondary, and RequestActionButton for "Open parent". Only the text block is one accessible element, so VoiceOver can reach "Open parent". Pending approvals and questions already render as cards above that slot.
  • Docs: docs/user/cursor.md said sending from a projected Cursor child starts a new agent; it now says the child is read-only and to send messages from the parent thread. docs/user/thread-sidebar.md gets one sentence: subagent threads started by the agent can't take messages; message the parent thread instead.

Surfaces: the composer is the only send entry point on web (command palette and keybindings route through it) and on mobile (ThreadComposer; the outbox drain would hit the server guard). Stop, queue, and steer were already unavailable because the child has no run (#13614).

Verification

  • ClaudeReplayFixtures.integration.test.ts (new): replays the recorded subagent Claude transcript through the full orchestrator. It then dispatches message.dispatch to the native child and asserts the OrchestratorSubagentThreadReadOnlyError tag and its user-facing text, an unchanged child event sequence, no runs, and unchanged messages. Without the guard, the same dispatch commits a new run on the child (I checked by removing it).
  • runtimeLayer.test.ts (new): a provider-native child thread with a Codex-style message-mode question (node, runtime request, user_input_request item written to the child). A plain message.dispatch is refused with no message written, and runtime-request.respond still resolves the request, completes the item, and commits the answer message. With the guard back inside dispatchMessage, the answer is refused (checked).
  • OrchestratorMcpToolkit.integration.test.ts (extended): in the Codex delegated-task-status replay, the delegate_task child is a subagent thread but not provider-native, and it still accepts both a running and a queued t3_thread_send follow-up.
  • packages/client-runtime threadExecution.test.ts: 22 passed. Provider child gives status and timing, a delegate_task child and a normal thread give null, runless working state ignores non-provider threads, the formatter output is checked for starting, working, completed, and cancelled, and the effort formatter is checked for a catalog label, an uncatalogued value, and no effort (absent or an unrelated option id). 25 passed.
  • Also ran: OrchestratorReplayFixtures.integration.test.ts (87 passed), web MessagesTimeline.logic/BranchToolbar.logic (208 passed), mobile threadActivity/threadAgentsPresentation (78 passed), server runtimeLayer/ClaudeReplayFixtures/UserFacingErrors/ThreadManagementService (65 passed).
  • tsc --noEmit on contracts, client-runtime, web, mobile, server: no errors. vp lint on touched files: no new findings. vp run knip:check: clean.
  • Not run: browser, desktop, or simulator checks (no dev servers per maintainer rule), so there are no before/after images yet. The bar needs a visual pass in a real client before landing. Repo-wide checks were not run either.

Model: Claude Opus 5.5 (Claude Code)

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.7 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.1 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.4 KiB—29.3 KiB✅
      CodexLive turn messages—1—8✅
      ClaudeTotal thread wire—4.9 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.7 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—20.8 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 44f8e2f · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a substantial cross-platform behavior change that replaces the composer and alters server dispatch for provider-native subagents. Unresolved high-severity risks remain around queued sends bypassing read-only enforcement and mobile queued-message edits being discarded.

      Not approved because:

      • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/b6d6fa17c0ce6f7f87e06f689f0c847452245470/apps/web/src/components/chat/ChatComposer.tsx#L5068

      When hideThreadSettings is true, the unmounted ProviderModelPicker can still set isComposerModelPickerOpen to true via the global modelPicker.toggle shortcut. Because this ChatComposer persists across navigation, that stale state makes the picker open immediately when returning to a normal thread; reset it while thread settings are hidden.

      No longer relevant as of d4585a131d8815084dfc7516f5fcc53a04dc5490

      @@ -8767,4 +8778,15 @@
      87678778 case "provider-session.detach":
      87688779 yield* dispatchProviderSessionDetach(command, events, effects);
      87698780 break;
      8770- case "message.dispatch":
      8781+ case "message.dispatch": {
      8782+ // The provider owns a native subagent's conversation, so a sent
      8783+ // message has nowhere to go. Only sends are refused: answers to the
      8784+ // subagent's own questions reuse dispatchMessage and must still land.
      8785+ const thread = yield* projectionStore
      8786+ .getThread(command.threadId)
      8787+ .pipe(
      8788+ Effect.mapError(
      8789+ (cause) => new OrchestratorProjectionError({ threadId: command.threadId, cause }),
      8790+ ),
      8791+ );
      8792+ if (isProviderNativeSubagentThread(thread)) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High orchestration-v2/Orchestrator.ts:8792

      Pre-existing queued sends still execute on provider-native subagent threads, bypassing the new read-only protection. handleTerminalRun unconditionally calls startNextQueuedRun when an active run finishes, and queue.resume can do the same, so queued message.dispatch runs created before this guard reaches dispatchOnce are forwarded to the provider. Enforce the read-only check when promoting queued runs (and resume), or cancel those queued sends during migration.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/server/src/orchestration-v2/Orchestrator.ts around line 8792:
      
      Pre-existing queued sends still execute on provider-native subagent threads, bypassing the new read-only protection. `handleTerminalRun` unconditionally calls `startNextQueuedRun` when an active run finishes, and `queue.resume` can do the same, so queued `message.dispatch` runs created before this guard reaches `dispatchOnce` are forwarded to the provider. Enforce the read-only check when promoting queued runs (and resume), or cancel those queued sends during migration.
    5. @@ -1251,20 +1233 @@
      1251- }
      1252- }
      1253- bottomInset={composerBottomInset}
      1254- onChangeDraftMessage={props.onChangeDraftMessage}
      1255- onPickDraftMedia={props.onPickDraftMedia}
      1256- onPickDraftFiles={props.onPickDraftFiles}
      1257- onNativePasteImages={props.onNativePasteImages}
      1258- onNativePasteText={props.onNativePasteText}
      1259- onRemoveDraftImage={props.onRemoveDraftImage}
      1260- onStopThread={props.onStopThread}
      1261- onSendMessage={handleSendMessage}
      1262- onShowUsageLimits={showUsageLimits}
      1263- canSwitchProvider={props.canSwitchThreadProvider}
      1264- onUpdateModelSelection={props.onUpdateThreadModelSelection}
      1265- onUpdateRuntimeMode={props.onUpdateThreadRuntimeMode}
      1266- onUpdateInteractionMode={props.onUpdateThreadInteractionMode}
      1267- onExpandedChange={setComposerExpanded}
      1268- onEditorFocusChange={handleComposerFocusChange}
      1269- />
      1270- </>
      1233+ {isProviderNativeSubagentThread(props.selectedThread.source) ? (
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High threads/ThreadDetailScreen.tsx:1233

      Provider-native threads still expose ThreadFeed's pending-message edit action, but this branch renders only ProviderSubagentBar, so an edited outbox message has no composer in which to modify or send it. Pressing the visible ComposerQueuedEditBanner cancel action then clears the queued-edit draft and permanently discards the message. Disable pending-message editing and its queued-edit banner for provider-native threads, or render a composer that can complete the edit.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @apps/mobile/src/features/threads/ThreadDetailScreen.tsx around line 1233:
      
      Provider-native threads still expose `ThreadFeed`'s pending-message edit action, but this branch renders only `ProviderSubagentBar`, so an edited outbox message has no composer in which to modify or send it. Pressing the visible `ComposerQueuedEditBanner` cancel action then clears the queued-edit draft and permanently discards the message. Disable pending-message editing and its queued-edit banner for provider-native threads, or render a composer that can complete the edit.
    6. juliusmarminge merged thisd3179b6

    7. juliusmarminge closed this

Sign in to join this conversation.