[FEATURE] Stop/SubagentStop hook payloads should expose token usage, cost, and duration natively

Resolved 💬 2 comments Opened Jun 9, 2026 by pmonday Closed Jun 13, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Currently, the Stop and SubagentStop hook payloads include tool_calls, stop_reason, and effort — which is great. However, the fields that are most valuable for AI usage tracking are not yet present.

Missing fields (visible in /usage but absent from hook payload):

| Field | Where it appears today | Why hooks need it |
|---|---|---|
| input_tokens | /usage screen | Transcript parsing is fragile; breaks on sidechain messages and concurrent sessions |
| output_tokens | /usage screen | Same |
| cache_read_input_tokens | /usage screen | Critical for cost calculation |
| cache_creation_input_tokens | /usage screen | Critical for cost calculation |
| total_cost_usd | /usage screen | Direct cost attribution without needing per-model pricing tables |
| api_duration_ms | /usage screen | Useful for latency tracking |
| wall_duration_ms | /usage screen | Wall time vs API time ratio |

Current workaround: We parse the JSONL transcript file on every Stop/SubagentStop event, filtering by timer start time, deduplicating by message UUID, and skipping sidechain messages. This is brittle — it breaks when transcript structure changes, requires file I/O on every stop event, and is hard to get right across parallel subagent sessions.

Proposed Solution

Requested change: Add a usage object to the Stop and SubagentStop hook payloads containing the aggregated token counts and optionally cost/duration for the session:

{
  "usage": {
    "input_tokens": 45230,
    "output_tokens": 8410,
    "cache_read_input_tokens": 312000,
    "cache_creation_input_tokens": 44800,
    "total_cost_usd": 0.412,
    "api_duration_ms": 18400,
    "wall_duration_ms": 94000
  }
}

For SubagentStop, this should reflect the subagent's own usage only (not the full session).

Impact: This would let tools like Parallel Hours accurately capture AI usage costs and token counts without fragile transcript parsing, and would make the hook system sufficient for production-grade AI observability without requiring file access.

Alternative Solutions

_No response_

Priority

Medium - Would be very helpful

Feature Category

Developer tools/SDK

Use Case Example

I've created a developer tool at parallelhours.io, this tool integrates with AI environments to help quantify:

  • AI Leverage (parallel tasks that a person is doing)
  • AI Usage and Effectiveness (LOC, Tokens, Cost)
  • AI Environment (model, reasoning effort, etc...)

Much of the basic data that should be available from AI agents and the underlying model usage is simply not available, agent usage is difficult to quantify and track.

When a task starts, timers and sessions start up, stop, and log themselves

When a task completes, each subagent should be able to log

  • tokens used FOR THE SUBAGENT
  • time spent
  • reasoning and tool interactions required

Then when the full task is complete, the sub-agent consumption is aggregated in the tool to help quantify and map ai effectiveness. Without the subagent data, the transcripts have to be parsed resulting in inaccuracies.

Additional Context

_No response_

View original on GitHub ↗

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