Feature Request: Expose sub-agent context sizes in statusline API

Resolved 💬 2 comments Opened Dec 29, 2025 by filter-tiago Closed Dec 29, 2025

Feature Request

Summary: Expose per-sub-agent context window usage metrics in the statusline hook API.

Current Behavior

The statusline hook receives comprehensive metrics about the main conversation context:

  • context_window.current_usage.input_tokens
  • context_window.total_input_tokens
  • context_window.total_output_tokens
  • etc.

However, when sub-agents are spawned via the Task tool, their context usage is not exposed to the parent session's statusline.

Proposed Enhancement

Add sub-agent context metrics to the statusline input JSON, for example:

{
  "context_window": { ... },
  "sub_agents": [
    {
      "agent_id": "abc123",
      "subagent_type": "Explore",
      "status": "running",
      "context_usage": {
        "input_tokens": 15000,
        "output_tokens": 2500
      }
    }
  ]
}

Use Cases

  1. Resource monitoring: Users managing context across multiple agents need visibility into total consumption
  2. Cost tracking: Understanding which agents consume the most tokens
  3. Debugging: Identifying runaway agents that are consuming excessive context
  4. Custom UIs: Building statuslines that show aggregate context usage across all active agents

Current Workarounds

  • Parse agent transcript files (agent-{id}.jsonl) manually - requires token counting library
  • Use SubagentStop hook to log completion data - only available after agent finishes
  • Use Agent SDK instead of CLI - significant overhead for simple monitoring needs

Additional Context

The isolation of sub-agent context windows is valuable for preventing context pollution. This request is specifically about exposing metrics, not changing the isolation model. Read-only access to sub-agent usage wouldn't compromise the design principles.

---
Filed via Claude Code CLI

View original on GitHub ↗

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