Add token usage and cost fields to `Stop` and `UserPromptSubmit` hook events
Resolved 💬 3 comments Opened Apr 19, 2026 by PDE-AI Closed May 26, 2026
Feature Request
Currently, the Stop and UserPromptSubmit hook events do not include token usage or cost data. The only hook that receives cost information is SessionEnd, which fires once at session termination.
Use Case
I'd like to calculate per-prompt cost by capturing cost before (UserPromptSubmit) and after (Stop) each prompt and reporting the delta. This would give users real-time cost visibility per interaction without needing to manually run /cost.
Proposed Change
Add token usage and cost fields to the Stop hook input:
{
"session_id": "abc123",
"hook_event_name": "Stop",
"stop_reason": "end_turn",
"token_usage": {
"input_tokens": 1500,
"output_tokens": 800,
"cache_read_input_tokens": 12000,
"cache_creation_input_tokens": 3000
},
"cost_usd": 0.042,
"cumulative_cost_usd": 0.58
}
A cumulative cost field in UserPromptSubmit would also allow calculating the delta.
Why This Matters
- Users on pay-per-use APIs (e.g., AWS Bedrock) have no programmatic way to track per-prompt costs
- The data clearly exists in memory (accessible via
/cost) but is not exposed to hooks - This would enable simple hook scripts to log, display, or alert on per-prompt spend
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗