Skip to content

Log subagent token usage, costUsd, and effective model ID in session logs and agent_output #1195

Backlog

Description

@goolamabbas

Environment

  • Command Code version: 1.93.6
  • OS: macOS (darwin 25.6.0)
  • Model tested: stepfun/step-5 ($10/mo plan)

Context

Ran an 11-worker blind-review subagent workflow (5 parallel background advisors, 5 parallel background reviewers, 1 foreground chair) end-to-end on cmd 1.93.6 using custom agents in ~/.commandcode/agents/ (omitted tools cleanly enforced 0 worker tool calls, 11/11 workers completed on attempt 1, 95.7% parent cache hit rate).

Feature Requests

1. Per-subagent token usage, costUsd, and effective model ID logging (primary ask)

Currently, local session JSONLs under ~/.commandcode/projects/ record usage (inputTokens, cacheReadTokens, outputTokens, costUsd) only for the parent coordinator's turns (e.g., 31 parent turns summing to $0.7979), while the 11 subagent workers' token usage, credit draw, and resolved model IDs are not written to local session logs or returned in agent_output.

Requested:

  • Include per-worker token usage (inputTokens, cacheReadTokens, outputTokens, costUsd) and resolved model ID in agent_output metadata and/or child session JSONLs (or rolled up distinctly in the parent session log).
  • Makes full-run credit accounting and multi-agent cost verification transparent for users on plan credits.

2. Optional ambient-instruction opt-out for isolated/blind subagents (nice-to-have)

For pure-reasoning or blind-review custom agents (where tools is already omitted), an optional frontmatter flag to skip project/ambient workspace instructions (similar to Claude Code's omitClaudeMd: true) would tighten context isolation further.

3. Clarify Desktop beta /agents support in docs (minor)

Noting clearly in commandcode.ai/docs/agents whether ~/.commandcode/agents/ custom subagents are supported in Desktop beta builds alongside CLI.

Reproducer & Reference

Activity

  1. roy-tong commented on Dec 4, 2026

    @roy-tong

    Strong request. Once you run 10+ parallel subagents, parent-only session logs hide both per-worker token burn and which model actually handled each sub-run.

    Two edge cases worth pinning when adding per-subagent JSONL logging: keep parent_session_id / subagent_id disjoint so downstream rollups never double-count parent + child totals, and deduplicate sibling content blocks by message_id (plus separate 5m vs 1h cache writes) so multi-block turns do not inflate costUsd. We published two tiny open fixtures for those exact checks if useful:

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions