A new helper computes used and max token counts from the current message history and model, and calls notifyMetadataChanged({ context_usage }) whenever the totals change. This feeds live context-window usage indicators, such as a status bar, rather than being purely internal bookkeeping.
Names in the bundlecontext_usage
Documented inclaude-code/agent-sdk/python
The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.
Confirmed since
Anthropic's documentation has since written up context_usage, on Agent SDK reference - Python.
async def get_context_usage(self) -> ContextUsageResponseagent-sdk/python see the edit
One source agreesOne thing we can check says the same as this entry.
Anthropic's documentation agrees
Anthropic's documentation has since written up context_usage, on Agent SDK reference - Python.