[FEATURE] Expose sub-agent token usage in PostToolUse hook response

Resolved 💬 3 comments Opened Apr 4, 2026 by nullnull-kim Closed May 14, 2026

Preflight Checklist

  • [x] I've searched existing issues and didn't find a match
  • [x] I've read the documentation
  • [x] I can reproduce this issue consistently

What's Wrong?

When the Agent tool completes, the task-notification includes <usage> metadata with total_tokens, tool_uses, and duration_ms. However, this data is not exposed to PostToolUse hooks — the tool_response for Agent tool calls does not contain any token usage information.

This makes it impossible to track per-sub-agent token consumption from hooks, even though the data already exists internally.

Example of existing internal data (from task-notification):

<usage>
  <total_tokens>37229</total_tokens>
  <tool_uses>22</tool_uses>
  <duration_ms>51993</duration_ms>
</usage>

What Should Happen?

PostToolUse hooks should receive token usage data in tool_response when the completed tool is an Agent call. For example:

{
  "tool_name": "Agent",
  "tool_response": {
    "result": "...",
    "usage": {
      "total_tokens": 37229,
      "tool_uses": 22,
      "duration_ms": 51993
    }
  }
}

Use Case

  • Per-agent token budget tracking: Monitor which sub-agents consume the most tokens and optimize delegation strategies
  • Cost attribution: Break down session costs by sub-agent role (e.g., explore vs. code-review vs. test-runner)
  • Budget enforcement: Warn or block when a single sub-agent exceeds a token threshold

Claude Model

claude-opus-4-6

Is this a regression?

No, this never worked

Claude Code Version

2.1.88 (Claude Code)

Platform

Other

Operating System

Windows 11 Home 10.0.26200

Terminal/Shell

PowerShell

View original on GitHub ↗

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