Show live token usage on backgrounded sub-agent placeholder

Resolved 💬 3 comments Opened Apr 28, 2026 by mofolom Closed May 2, 2026

Problem

When a sub-agent is launched with run_in_background: true, the parent thread renders a placeholder row like:

Frontend Developer(Ship W29 S-BPB pipeline board)
  ⎿  Backgrounded agent (↓ to manage · ctrl+o to expand)

There is no visibility into the agent's token consumption while it runs. Token totals only appear in the final completion payload (<usage><total_tokens>...</total_tokens></usage>), which surfaces after the agent finishes — sometimes 10+ minutes later.

For workflows that fan out 3+ parallel worktree-isolated agents (compound-engineering pattern), this matters because:

  • A runaway agent (stuck in retry loop, broken tool call) cannot be detected until it completes — by which time it has burned significant tokens
  • No way to budget across parallel agents in real time
  • The orchestrator has to guess whether agent is making progress or hung

Proposed UX

Render the live cumulative token count on the backgrounded-agent row:

Frontend Developer(Ship W29 S-BPB pipeline board)
  ⎿  Backgrounded agent (↓ to manage · ctrl+o to expand · 47.2k tok)

Updated each time the sub-agent emits a turn. Could optionally show tool-use count too (47.2k tok · 23 tools).

Why it matters

Per-agent JSONL transcripts (<temp>/tasks/<agentId>.output) already contain message.usage blocks per turn — the data exists, just isn't bubbled up to the parent UI. Running tail -f <file> | jq '.message.usage' from a separate terminal works as a workaround, but requires the user to leave Claude Code and chase paths manually.

Workaround today

  • Read the final completion payload <usage> block
  • Tail the JSONL transcript externally (parent thread is forbidden from reading it — would overflow context)
  • Approximate via duration (highly imprecise — varies 50–500 tok/s based on tool mix)

None of these give the user a live view inside the parent thread.

Environment

  • Claude Code on Windows 11 Pro (10.0.26200), bash + PowerShell
  • Sub-agents launched with Agent tool, run_in_background: true, isolation: "worktree"
  • Worktree-isolated parallel-agent pattern (3 simultaneous agents typical)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗