The whole hunk
from line 84, old and new numbered
/
lines
from line 84
8484| `total_cost_usd` | Included. Counts subagent requests alongside the top-level loop |
8585| `modelUsage` / `model_usage` | Included. Counts subagent requests alongside the top-level loop, broken down by model |
8686
87In [single message input mode](/docs/en/agent-sdk/streaming-vs-single-mode#single-message-input), when background subagents are still running at the end of the final turn, Claude Code waits for them, up to the cap described in [background tasks at exit](/docs/en/headless#background-tasks-at-exit), before emitting the result.
88
8789The following examples iterate over the message stream from a `query()` call and print the total cost when the `result` message arrives:
8890
8991<CodeGroup>