Skip to content

fix: count sub-agent tokens in scode-shepherd status - #516

Merged
scode merged 1 commit into
mainfrom
shepherd-subagent-tokens
Nov 9, 2026
Merged

scode merged 1 commit into
mainfrom
shepherd-subagent-tokens

Conversation

@scode

@scode scode commented Nov 8, 2026

Copy link
Copy Markdown
Owner

shepherd status is where a run's token totals come from, and the supervisor's final report repeats them. It counted
only each worker and reviewer session's own thread. Codex runs a session's native sub agents as threads of their own,
and their tokens never reach the parent's total. In a benchmark run, one worker session started ten sub agents, and
those used more tokens than all five worker sessions together, so the reported worker use was about half the real one.

The runner now adds each session's sub agents, at any depth, found through the parent link codex writes at the top of
every sub agent's session file, and status says how many sub-agent threads the worker and reviewer totals include.
Under shepherd drive, the headless mode where the script runs the supervisor and so records its token use (an
interactive supervisor's is not recorded at all), that total includes the supervisor's sub agents the same way, with
their count. A codex exec that a session starts from its shell has no parent link and is still not counted.

The same run's supervisor did its read-only research with codex exec --ephemeral, which writes no session file, so
those sessions could be neither counted nor checked afterwards for what they were told and read. The skill now tells the
supervisor not to pass that flag.

`shepherd status` is where a run's token totals come from, and the supervisor's final report repeats them. It counted
only each worker and reviewer session's own thread. Codex runs a session's native sub agents as threads of their own,
and their tokens never reach the parent's total. In a benchmark run, one worker session started ten sub agents, and
those used more tokens than all five worker sessions together, so the reported worker use was about half the real one.

The runner now adds each session's sub agents, at any depth, found through the parent link codex writes at the top of
every sub agent's session file, and `status` says how many sub-agent threads the worker and reviewer totals include.
Under `shepherd drive`, the headless mode where the script runs the supervisor and so records its token use (an
interactive supervisor's is not recorded at all), that total includes the supervisor's sub agents the same way, with
their count. A `codex exec` that a session starts from its shell has no parent link and is still not counted.

The same run's supervisor did its read-only research with `codex exec --ephemeral`, which writes no session file, so
those sessions could be neither counted nor checked afterwards for what they were told and read. The skill now tells the
supervisor not to pass that flag.
@scode
scode marked this pull request as ready for review November 9, 2026 02:43
@scode
scode merged commit c0082a0 into main Nov 9, 2026
5 checks passed
@scode
scode deleted the shepherd-subagent-tokens branch November 9, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant