Skip to content

Run metrics miss the tokens of agent CLIs a session starts itself #1639

Open

Description

@JacobStephens2

This was generated by AI during triage.

What happens

Run metrics take tokens only from the Harness's own event stream: Claude's result event and Codex's turn.completed. When a session starts another agent CLI itself, its tokens are never counted and only its elapsed time lands in the Step. Examples are claude -p … or codex exec … run through Bash, which an orchestrating skill does for each sub-agent. Claude Code's own Agent-tool subagents are probably included in the root result, but that is inferred, not documented.

So a Custom process whose skill Step orchestrates sub-agents across providers looks nearly free next to a Built-in process, even when it spends several times the tokens. That undermines any comparison of Processes or Arms (#1468), as well as the per-Command cost and token figures a Day shift reads. The details, with file and line evidence, are in docs/research/process-comparison-cost-accounting.md. The hand-run comparison in #1628 has to parse the sub-agents' streams with its own script to work around this.

What it could look like

  • (a) Each session's environment names a directory, such as THIRDSHIFT_CHILD_STREAMS. Skills are asked to write each child CLI's stream-json / --json output there, and thirdshift sums it into the session's Run metrics by observed model, as it does for its own sessions.
  • (b) thirdshift wraps the claude and codex binaries on the session's PATH with shims that tee each child's stream into that directory, so skills need no changes. This is more invasive, and it is harness-version-sensitive.
  • (c) Only record that child CLIs ran, and flag the session's tokens as incomplete rather than counting them.

Either way, report child tokens separately from the session's own, so nothing that is counted today changes meaning.

Open questions

  • Is a convention that skills opt into (a) enough, or must it work for skills that don't know about it, which means (b)?
  • Should Run metrics carry a "tokens incomplete" flag whenever a session ran a known agent CLI that wasn't captured?
  • Does any of this belong in the Experiment's Arms, so that Spec: Custom-runner Arms for process Experiments #1468's Process-defined Arms count the same way?

Related: #1468, #1484, #1531, #1628.

Activity

  1. added
    enhancement
    needs-triage
    on Oct 30, 2026
  2. added
    in-progress
    and removed
    needs-triage
    on Nov 10, 2026
  3. JacobStephens2 commented on Nov 10, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation summary

    Investigated #1639 against main at 0009a53. The shell-launched child-CLI accounting gap is supported by the current code, but the capture and completeness contract needs a Day shift decision before implementation.

    Evidence:

    • src/session/recording.rs:174-310 records the selected Harness stream and its supported retained amendments. There is no child-stream collection convention.
    • src/harness/codex/events.rs:112-117 keeps command output in a tool result. src/harness/interpretation/stream/events.rs:231-254 similarly keeps Claude tool-result content as tool evidence. Neither recursively decodes child CLI JSON into usage events.
    • src/session/usage.rs:75-245 derives measurements from normalized usage, model calls and turn totals. src/logs/session_signals.rs:120-170 reads those normalized facts rather than parsing arbitrary tool output. Child usage absent from these facts therefore cannot contribute.
    • The issue's terminal-events-only description is too narrow: current accounting also reconciles model-call measurements and retained evidence, preserving partial totals and normalizing cache counts.
    • Experiments already share Session usage and freeze comparison prices: src/evals/experiment/usage.rs:26-32, src/evals/experiment/accounting.rs:16-107 and src/trial/accounting.rs:68-94. Missing usage or observed Model prices can produce an accounting-gap Void through src/evals/experiment/execution.rs:332-350. The dated research note should not be treated as the current Experiment pricing specification.

    This is distinct from open #1651, which covers native Codex subagents and observed Model attribution, and #1655, which covers Custom process metric persistence. The latter also qualifies this report's claim that a Custom process currently retains ordinary Run metrics: src/logs/command_record.rs:373 still excludes Process records.

    Recommended direction: start with an opt-in child-stream contract, keep existing Session measurements unchanged, and expose captured child measurements separately by observed Model. Reuse the existing interpreters and usage rules. Preserve child evidence through worktree cleanup, identify ownership per Session/invocation, and handle repeated files, nested children, interrupted streams and Resumes without double counting. Define completeness explicitly; an empty directory cannot establish that no child CLI ran. Propose the implementation split through the questionnaire below. No duplicate issue or GitHub comment is proposed.

    Questionnaire

    For the Day shift deciding #1639: repository inspection supports the missing shell-launched child usage, but does not settle the capture policy. These decisions will make the work implementable.

    1. Is an opt-in stream directory sufficient for the first release, or must unmodified skills be captured automatically? Recommend the opt-in convention first. Requiring transparent capture means separately shaping PATH wrappers, supported CLI versions and bypass behavior.

    2. Approve or amend this proposed split: (A) Session-owned child registration, stream collection and retained evidence, initially for Claude and Codex; (B), blocked by A, separate child usage and coverage reporting in Run metrics, CLI/Console views and documentation; (C), blocked by A and the shared reporting contract, Experiment discovery and frozen-price accounting for those children. Keep native Codex accounting in Codex sessions miss native sub-agent tokens and record no observed Model #1651 and Custom process metric persistence in Custom process Commands record no Run metrics, and their header shows the default harness #1655. Automatic wrappers would be a separate follow-up if required by question 1.

    3. What coverage guarantee should the opt-in contract promise? Recommend distinguishing unknown coverage, explicitly declared complete capture, and known missing/partial capture. Should a missing declared child stream become an Experiment accounting gap? An absent registration alone cannot prove completeness, and shell-command matching cannot guarantee detection of every invocation.

    4. Should Experiment Arms consume the same captured child evidence automatically, without a new Arm setting? Recommend preserving existing own-Session figures, showing child figures separately, and using the existing frozen-price/accounting-gap rules for comparison totals. Child durations must not be added to elapsed wall time, and native subagents already represented by Harness usage must not be imported again.

  4. added
    ready-for-human
    and removed
    in-progress
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions