feat(orchestration-v2): populate subagent observability from providers (2/5) - #4629
Draft
shivamhwp wants to merge 2 commits into
Draft
feat(orchestration-v2): populate subagent observability from providers (2/5)#4629shivamhwp wants to merge 2 commits into
shivamhwp wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the 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. Comment |
This was referenced Jul 27, 2026
shivamhwp
force-pushed
the
subagent-obs/02-adapters
branch
from
July 27, 2026 23:03
9296337 to
760a4c2
Compare
shivamhwp
force-pushed
the
subagent-obs/01-contracts
branch
from
July 28, 2026 15:31
877ef38 to
12b0111
Compare
shivamhwp
force-pushed
the
subagent-obs/02-adapters
branch
from
July 28, 2026 15:31
760a4c2 to
f3666e9
Compare
Base automatically changed from
subagent-obs/01-contracts
to
t3code/codex-turn-mapping
July 28, 2026 19:27
shivamhwp
force-pushed
the
subagent-obs/02-adapters
branch
from
July 28, 2026 19:27
f3666e9 to
2565ea0
Compare
shivamhwp
force-pushed
the
t3code/codex-turn-mapping
branch
from
July 28, 2026 20:12
313ae4d to
f117a4a
Compare
shivamhwp
changed the base branch from
t3code/codex-turn-mapping
to
subagent-obs/01-contracts
July 28, 2026 20:12
Fills in the data model added by the previous PR. Every adapter now reports what its subagents are actually doing: role provenance, token usage, recent activity, and per-activation records. Usage needs two merge strategies because providers report it differently. Codex sends cumulative snapshots per thread, so those merge by maximum — duplicate and late out-of-order frames then leave the total unchanged instead of inflating it. Claude reports per activation, so lifetime usage accumulates only the delta since the previous snapshot. A subagent identity is reusable, so completing an activation leaves it at "idle" rather than "completed"; the timeline row for that activation is still recorded as completed via the status mapping. A Codex subAgentActivity frame carries no model of its own, so agents registered from one were recorded with none at all — the common case for Codex-native subagents, which then showed a role and a token count but no model. They are recorded against the turn's model selection, which is what they actually run on. Three activation-lifecycle fixes in the Claude adapter, found in review: - A resume that raced past settle was pre-opened by the wake buffer, which erased the terminal status the reopen check reads. The resume then reused the finished activation instead of starting a new one, so its ordinal stopped matching reality and its usage was measured against the previous activation's totals — clamping the delta to zero and silently dropping the resumed run's tokens. The pre-open now records that it happened, and the reopen check honours it. - A replayed "waiting" frame could resurrect a settled subagent; only pending/running were guarded before. - A duplicate terminal frame re-stamped completedAt, drifting the recorded completion time. Codex already preserved it; Claude now matches. Reuse across runs is deliberately not addressed here — a subagent row still carries the run it was spawned under. That is the next PR.
The adapter's workflow projection was covered in isolation and the panel derivation was covered against synthetic agents, but nothing drove real workflow frames through the orchestrator to the projection the client receives. Adds a claude_workflow replay fixture: a local_workflow task with two phases and two members, asserted on the resulting projection. Pins what the panel groups by — that members claim declared phases, that their membership points at the coordinator that actually reached the projection, and that the coordinator's usage still covers its members so subtracting theirs cannot go negative. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
shivamhwp
force-pushed
the
subagent-obs/02-adapters
branch
from
July 28, 2026 20:26
bc22aac to
2567faf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of five stacked PRs replacing #4551. Stacked on #4779 — review that first; this diff is against it, not the base branch.
PR 1 added the schema, migration, and storage with adapters on neutral defaults. This one makes the adapters actually populate it, across Codex, Claude, Cursor, OpenCode and ACP: role provenance, token usage, recent activity, and per-activation records.
Two usage strategies, because providers differ
Codex reports cumulative usage per thread, so those snapshots merge by maximum — a duplicate or late out-of-order frame then leaves the total unchanged rather than inflating it. Claude reports per activation, so lifetime usage accumulates the delta since the previous snapshot. Using either strategy for the other provider double-counts or freezes the number, so they are separate functions with their own tests.
A subagent identity is reusable, so finishing an activation leaves it at
idlerather thancompleted. The timeline row for that activation is still recorded as completed, via PR 1's status mapping.Three activation-lifecycle bugs found in review
All in the Claude adapter, all fixed here:
waitingframe could resurrect a settled subagent. Onlypending/runningwere guarded.completedAt, drifting the recorded completion time. Codex already preserved it; Claude now matches.Explicitly not here
Reuse across runs. A subagent row still carries the run it was spawned under, so a later run's update can still be dropped by routing — visible in the
subagent_continuefixture. That is PR 3, deliberately kept separate because it is the subtle part.Testing
Typecheck and lint clean. Server 1,682 passing; whole-repo run 5,460 passing (the only failures are pre-existing
apps/desktopcollection errors from a broken local Electron install, untouched by this PR).Reviewed by an independent agent pass before opening; the three lifecycle bugs above came out of it and are fixed in this commit.
Note
Populate subagent observability with activation lifecycle events and usage tracking across providers
subagent_activation.updatedevent emission to all provider adapters (ACP, Claude, Codex, Cursor, OpenCode) so each activation has its own lifecycle record with status, timing, usage, and ordinal.mergeCumulativeSubagentUsageandaccumulateCumulativeSubagentUsagein SubagentObservability.ts to correctly compute lifetime token/tool-use totals across multiple activations without double-counting.appendSubagentActivityto track human-readable activity summaries on subagents, bounded to 6 entries with adjacent-duplicate deduplication.providerSubagentRoleso provider-supplied role names are tagged withsource: 'provider'rather than the app default.statusafter completion is now'idle'rather than'completed';currentActivationIdis cleared on settlement andactivationCountincrements only on new activations.task_progressframes, including phases, membership, attempt tracking, andresumePendingflag to correctly separate activations across wake-buffer replays.'pending'status withactivationCount: 0instead of'running'withactivationCount: 1.📊 Macroscope summarized 2565ea0. 9 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.