You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: attribute subagent volume to the model that dispatched it
The tokens report read one model per session transcript (its head, or its tail as a fallback) and pinned every subagent in it to that model. Long sessions switch models with /model, so in a 7d sample 135 of 269 agents were attributed to a model the session was not on when it dispatched them, and the dispatch report - which stamps the model at dispatch time - disagreed with the tokens report about the same window.
Each agent now resolves its session model in this order: the assistant message carrying the tool_use id named by the agent sidecar (in the session transcript, or in the parent agent transcript for nested agents), then the model in effect at the agent transcript's first timestamp (max timestamp <= launch, since a resumed transcript is not in chronological file order), and only then the transcript head/tail as before. The --session filter for main sessions is now per line model, since a switched session no longer belongs wholly to one.
// One transcript is one agent, counted here for the same reason ss.agents
819
890
// is counted outside the per-model loop: a mid-run fallback splits the
@@ -1046,7 +1117,7 @@ if (process.argv[2] === "tokens") {
1046
1117
] : []),
1047
1118
"",
1048
1119
"Volume = tokens the subagent processed; cache reads are billed at the subagent's model rate, which is where routing saves.",
1049
-
"Session model is read from the head of each session transcript - the model it started on - so a mid-session /model switch or fallback attributes later subagents to the start model (the dispatch report does not have this limit). In a session long enough that its head names no model at all, the tail is read instead and that session is attributed to its LAST model, which is the opposite bias for those sessions.",
1120
+
"Session model is the model of the assistant message that DISPATCHED the agent, matched through the toolUseId in the agent's sidecar - the same instant the dispatch report stamps, so a mid-session /model switch moves both reports together. Without a usable sidecar the model in effect at the agent's first timestamp is used, and failing that the head of the session transcript (or its tail, when the head names no model at all).",
0 commit comments