get_token_use
Read what each agent spent in tokens since midnight, with its conversation size and compactions, every agent's running totals, and the tools whose results filled the conversations.
read-onlyidempotentCLI onlySystem
Calling it#
curl -X POST http://127.0.0.1:8787/komrad.system.v1.SystemService/GetTokenUse \
-H 'Content-Type: application/json' \
-d '{}'komrad rpc get-token-useRequest#
GetTokenUseRequest#
| Field | Type | Description |
|---|---|---|
agent_id | uuid | The agent whose running totals, conversation sizes and tools to read alongside every agent's. Unset reads every agent's alone. |
Response#
GetTokenUseResponse#
| Field | Type | Description |
|---|---|---|
tokens | TokenCounts | The tokens every agent spent since midnight. |
agents | AgentTokenUse[] | Every agent that made a model call since midnight, the most tokens first. |
totals | TokenTotal[] | Every agent's running totals every five minutes since midnight, the last at the time of the read. |
tools | ToolTokenUse[] | Every tool every agent called since midnight, the most tokens first. |
agent_totals | TokenTotal[] | The named agent's running totals every five minutes since midnight. Empty when the request names no agent. |
agent_conversation | ConversationSize[] | The named agent's conversation size at each model call since midnight, oldest first. Empty when the request names no agent. |
agent_tools | ToolTokenUse[] | Every tool the named agent called since midnight, the most tokens first. Empty when the request names no agent. |
Types#
TokenCounts#
TokenCounts is tokens split by what the model did with them.
| Field | Type | Description |
|---|---|---|
input | int64 | The prompt tokens the cache did not serve. |
cache_read | int64 | The prompt tokens the cache served. |
cache_write | int64 | The prompt tokens the model wrote to the cache. |
output | int64 | The tokens the model sent back, reasoning included. |
AgentTokenUse#
AgentTokenUse is what one agent spent in tokens today.
| Field | Type | Description |
|---|---|---|
agent_id | string | The agent's id. |
name | string | The agent's name when it made its latest model call. |
harness | string | The harness the agent runs on, such as |
cli_version | string | The version of the CLI that made the agent's latest model call. |
model | string | The model of the agent's latest model call. |
effort | string | The effort of the agent's latest model call. Empty when the CLI reported none. |
tokens | TokenCounts | The tokens the agent spent today. |
model_calls | int64 | How many model calls the agent made today. |
conversation_tokens | int64 | The agent's conversation size: the input, cache read and cache write tokens of its latest model call that counts toward its conversation. |
compactions | timestamp[] | When the agent's conversation shrank to under half its size today, as it does when the CLI compacts it, oldest first. |
latest_at | timestamp | When the agent made its latest model call. |
TokenTotal#
TokenTotal is the tokens model calls sent and got back from midnight up to a time.
ToolTokenUse#
ToolTokenUse is what one tool's calls sent back today, which every later model call in the conversation sends again.
| Field | Type | Description |
|---|---|---|
tool | string | The tool, as the CLI names it. |
tool_calls | int64 | How many times the tool was called. |
result_tokens | int64 | About how many tokens the calls sent back. |
commands | CommandTokenUse[] | The shell tool's calls split by the command they ran, the most tokens first. Empty for any other tool. |
ConversationSize#
ConversationSize is an agent's conversation size at one model call.
CommandTokenUse#
CommandTokenUse is what the shell tool's calls that ran one command sent back today.
| Field | Type | Description |
|---|---|---|
command | string | The program and subcommand the calls ran, such as |
tool_calls | int64 | How many tool calls ran the command. |
result_tokens | int64 | About how many tokens the calls sent back. |