Commit 9296337
committed
feat(orchestration-v2): populate subagent observability from providers
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.
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.1 parent 877ef38 commit 9296337
15 files changed
Lines changed: 1329 additions & 102 deletions
File tree
- apps/server/src/orchestration-v2
- Adapters
- testkit/fixtures
- subagent_continue
- subagent_v2_nested
- subagent_v2
- subagent
Lines changed: 32 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
1926 | 1928 | | |
1927 | 1929 | | |
1928 | 1930 | | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
1929 | 1937 | | |
1930 | 1938 | | |
1931 | 1939 | | |
| |||
1942 | 1950 | | |
1943 | 1951 | | |
1944 | 1952 | | |
1945 | | - | |
1946 | | - | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
1947 | 1956 | | |
1948 | | - | |
| 1957 | + | |
1949 | 1958 | | |
1950 | 1959 | | |
1951 | 1960 | | |
1952 | 1961 | | |
1953 | | - | |
1954 | 1962 | | |
1955 | 1963 | | |
1956 | 1964 | | |
1957 | 1965 | | |
1958 | | - | |
| 1966 | + | |
| 1967 | + | |
1959 | 1968 | | |
1960 | 1969 | | |
1961 | 1970 | | |
| |||
2073 | 2082 | | |
2074 | 2083 | | |
2075 | 2084 | | |
2076 | | - | |
| 2085 | + | |
2077 | 2086 | | |
2078 | 2087 | | |
2079 | 2088 | | |
| |||
2120 | 2129 | | |
2121 | 2130 | | |
2122 | 2131 | | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
2123 | 2149 | | |
2124 | 2150 | | |
2125 | 2151 | | |
| |||
0 commit comments