report_agent_usage
Record what one agent run cost an issue (local or mirrored/upstream): tokens by kind and machine time. Re-sending the same 'source' + 'externalId' updates that record instead of adding a second one, so a retry never doubles the spend. Omit a metric you did not measure — omitted is 'not reported', which is different from zero. Requires permission to edit the issue.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Issue key, e.g. 'UK-1'. | |
| host | No | Which host it ran on. | |
| note | No | Short note, e.g. the outcome. | |
| agent | No | Which agent did the work, e.g. 'claude-code'. | |
| model | No | Which model it ran on, e.g. 'claude-opus-5'. | |
| runId | No | The run this record belongs to, when one run reports several records (different models or hosts). | |
| source | Yes | Who is reporting, e.g. 'bg-agent-api'. Idempotency is scoped to it. | |
| costUsd | No | Cost in USD, if you know the rates that applied. | |
| endedAt | No | When the run ended (ISO 8601). | |
| startedAt | No | When the run started (ISO 8601). | |
| externalId | Yes | Your own key for this record (usually the run id). Re-sending it updates the record. | |
| inputTokens | No | Input (prompt) tokens. | |
| agentSeconds | No | Wall-clock seconds the run took. Machine time, not a worklog. | |
| outputTokens | No | Output (completion) tokens. | |
| cacheReadTokens | No | Cache-read tokens. | |
| cacheWriteTokens | No | Cache-write tokens. |