feat(orchestration-v2): add subagent observability #4551
t3code/codex-turn-mapping fromrefs/pull/4551/head·opened View on GitHubSummary#
Adds durable Orchestration V2 subagent observability on top of #2829. The projection now preserves provider-native and delegated agent identity, lifecycle, activation history, usage, workflow membership, and recent activity, and the web client exposes that state in a persistent Agents panel.
This PR is intentionally stacked on t3code/codex-turn-mapping and remains draft while the base PR and this implementation are reviewed.
What changed#
Contracts and persistence#
- Adds first-class subagent roles, provenance, kinds, usage, workflow metadata, recent activity, and
idlelifecycle state. - Adds ordered
OrchestrationV2SubagentActivationrecords so resumes, retries, and continuation turns remain independently inspectable. - Adds migration 43 and projection persistence for activations, including historical decode defaults, rebuild cleanup, and terminal cascades.
- Keeps nullable provider event attribution intact instead of inventing incorrect run or node ownership.
Provider and orchestration behavior#
- Normalizes Codex spawned-thread, token-usage, idle, resume, completion, and late thread-status behavior.
- Maps Claude workflow coordinators, phases, workers, retries, continuation turns, and attempt-gated reopen behavior.
- Emits activation updates for ACP, Cursor, OpenCode, and delegated Orchestrator subagents.
- Accumulates lifetime usage without double-counting cumulative provider snapshots and keeps per-activation usage separate.
- Routes child-thread events through the owning activation and repairs missing or stale activation state during rebuild and finalization.
Web UI#
- Adds a thread-scoped Agents right-panel surface with workflow grouping, statuses, roles, models, usage, recent activity, and activation history.
- Adds populated, empty, narrow-layout, light-mode, and dark-mode presentation states.
- Keeps the Agents tab, Thread Details, terminal, and right-panel controls in the right-panel flex toolbar when that panel owns the title bar, eliminating the narrow chat-column control that could overlap the global sidebar toggle.
- Keeps provider child threads internally for attribution, resume, history, recovery, and project cleanup, while excluding them from client HTTP/WebSocket shell snapshots and all web thread collections.
- Removes child-thread navigation from subagent timeline cards, item inspectors, Thread Details lineage, and stale child routes. Subagent progress and results remain visible in the parent conversation and Agents panel.
Screenshots#
![]() Workflow phases, provider-native agents, roles, usage, and status. |
![]() Expanded recent activity and ordered activation history. |
![]() Narrow layout with the Agents tab and controls remaining adjacent. |
![]() Dark-mode presentation. |
Empty state before the parent thread has any agents.
Important behavior#
Subagents may still own internal provider child threads. Those child threads are required for event attribution, history, resume behavior, recovery, and cleanup, but they are implementation details. Users see the agent's progress and result in the parent conversation and Agents panel; child threads are not emitted as user-facing conversations or exposed through navigation controls.
Verification#
- 118 focused server/web visibility and timeline tests pass, covering roots, user forks, explicit subagent lineage, provider-native node-child fallback, active/archived shells, and non-clickable subagent cards.
- 9 focused shell-stream and thread-management tests pass after applying the user-facing snapshot filter.
- 54 focused contracts, migration, persistence, usage, and run-cascade tests pass.
- 148 focused Codex, Claude, ACP, and client-derivation tests pass.
- Focused Cursor and OpenCode adapter suites passed during implementation.
- Targeted formatting and changed-file lint checks pass.
- Contracts, client-runtime, and web typechecks complete successfully; client-runtime reports one existing non-failing Effect suggestion.
- Server typecheck still reports the pre-existing
ClaudeAdapterV2.testkit.ts:349requestIderror plus unrelated Effect suggestions; no changed file reports a compiler error. - Earlier integrated verification covered populated and empty panels, activation disclosure, reload persistence, narrow layout, and light/dark modes. The final visual rerun was blocked by the device's preview automation and macOS AppleEvent transports, so the latest visibility/layout fix is covered by focused tests and source-level verification pending a manual browser pass.
No build or repo-wide test suite was run.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/orchestration-v2/ProviderEventIngestor.ts line 200Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -191,3 +191,10 @@191191 nodeId: input.event.subagent.id,192192 }),193193 ];194+ case "subagent_activation.updated":195+ return [196+ yield* makeDomainEvent(input, {197+ type: "subagent-activation.updated",198+ threadId: input.event.activation.threadId,199+ payload: input.event.activation,200+ runId: input.event.activation.runId,
🟡 Medium
orchestration-v2/ProviderEventIngestor.ts:200When
subagent_activation.updatedfires on an activation whoserunIdis explicitlynull, the normalized domain event is written with the surroundingProviderEventIngestInput.runIdinstead ofnull. The stored event's enveloperunIdthen disagrees withpayload.runId(which staysnull), misattributing the activation update to the current run. The root cause is thatmakeDomainEventresolvesrunIdviapayloadInput.runId ?? input.runId, so an explicitly passednullis indistinguishable from an omitted override and falls back to the ambient run id. The helper needs to distinguish an explicitnullfrom an absent value before falling back toinput.runId.No longer relevant as of a65967aa051536eef7ac0c61c4e9e1417fe9b055
🟡 Medium
When a thread's only relationships are subagents, filtering
subagentedges out ofrelationshipRowsmakes it empty, so the panel returnsnullat line 128. This hides the "Disconnect agent session" menu action (lines 182–203), which is the only UI that callsstopSession. A thread with an active provider session (canDetach === true) loses its only way to stop that session. The early return at line 127 (if (relationshipRows.length === 0) return null;) should not suppress the panel when detachable sessions still need to be surfaced. Consider checkingcanDetach(or other available actions) before returningnull, so the disconnect action remains reachable even when no non-subagent relationships exist.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/chat/ThreadRelationshipsControl.tsx around line 127: When a thread's only relationships are subagents, filtering `subagent` edges out of `relationshipRows` makes it empty, so the panel returns `null` at line 128. This hides the "Disconnect agent session" menu action (lines 182–203), which is the only UI that calls `stopSession`. A thread with an active provider session (`canDetach === true`) loses its only way to stop that session. The early return at line 127 (`if (relationshipRows.length === 0) return null;`) should not suppress the panel when detachable sessions still need to be surfaced. Consider checking `canDetach` (or other available actions) before returning `null`, so the disconnect action remains reachable even when no non-subagent relationships exist.Closing in favour of a five-PR stack. This bundled the whole feature into ~3,100 lines across 58 files, and every bug found while splitting it lived in a seam between the pieces — which is exactly what a diff that wide hides.
- #4626 (1/5) — data model, migration, status mapping
- #4629 (2/5) — adapters populate it
- #4662 (3/5) — reuse attribution
- #4663 (4/5) — Agents panel
- #4664 (5/5) — hiding subagent threads
Same work, reviewable in pieces, with the bugs found along the way fixed: the unbootable-server status mismatch, a Claude resume that silently dropped its tokens, reuse never being attributed to the run driving it, a workflow token total collapsing to "Usage unavailable", and mobile keeping a now-broken "Open subagent thread" affordance.
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
d92db531-3cc0-4738-8a81-7f9ffb6df2b8You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share