Skip to content

Token Usage Tool ​

One tool, record-token-usage, records the AI token usage of an agent session on an issue. kendo adds it to the issue's token total, and the sprint and epic totals add up their issues.

Send the counts your harness measured. A model cannot see its own token counts, so a number the assistant estimates makes the total wrong. For Claude Code, the Token Usage guide has a hook that reads the exact counts from the session.

Permission Model ​

  • You must have access to the issue's project (team membership or accessAllProjects)
  • Recording usage requires the Token Events: Create permission. The Member role has it; a role created after 2026-10-08 starts without it until an admin turns it on
  • Project owners and admins bypass these checks

record-token-usage ​

Record the token usage of one session for one model on an issue.

Parameters ​

ParameterTypeRequiredDescription
issue_idintegerOne ofThe numeric ID of the issue (provide issue_id or issue_key, not both)
issue_keystringOne ofThe issue key, e.g. "KD-0042" (provide issue_id or issue_key, not both)
modelstringYesThe model the tokens were spent on, max 255 characters (e.g. "claude-opus-5-5")
tokens_inintegerYesInput tokens, not counting cache reads or cache writes (minimum 0)
tokens_outintegerYesOutput tokens (minimum 0)
tokens_cache_readintegerNoTokens read from the prompt cache. Leave out when your harness does not report it; kendo stores it as "not reported", not 0
tokens_cache_creationintegerNoTokens written to the prompt cache. Same rule as tokens_cache_read
occurred_atstringNoWhen the usage happened, ISO 8601 (e.g. "2026-10-08T14:00:00Z"), max 255 characters. Defaults to now
external_event_idstringNoA globally unique id for this session and model, max 255 characters, e.g. "<session id>:<model>"

Behavior ​

  • Send one call per model the session used
  • With external_event_id, a second call for the same issue replaces the stored totals when its occurred_at is the same or later, so a retry never counts twice. The same id on another issue is ignored. See Resending a session
  • Without external_event_id, every call adds a new event
  • The event's source is recorded as mcp
  • Returns the issue and issue_token_total: the issue's total after the call. An ignored resend leaves that total unchanged

Example Prompt ​

Record this session's token usage on KD-0042: claude-opus-5-5, 1,200 tokens in, 350 out, 40,000 cache reads, 6,000 cache writes. Use session id 6f1c2b9e as the event id.