Usage Tracking
Reygent tracks cost, tokens, and duration for every agent invocation. Data flows from providers through UsageTracker to a summary displayed at the end of each run.
UsageInfo Fields
| Field | Type | Description |
|---|---|---|
costUsd | number | Total cost in USD |
durationMs | number | Wall-clock time of the invocation |
inputTokens | number | Prompt/input token count |
outputTokens | number | Completion/output token count |
numTurns | number | Number of agentic turns (Claude) |
All fields are optional. Providers report what they can.
Provider Coverage
| Provider | Duration | Input Tokens | Output Tokens | Cost | Turns |
|---|---|---|---|---|---|
| Claude | Yes | Yes | Yes | Yes | Yes |
| OpenRouter | Yes | Yes | Yes | Yes* | No |
| Gemini | Yes | Best-effort | Best-effort | No | No |
| Codex | Yes | Best-effort | Best-effort | No | No |
* OpenRouter cost depends on the upstream model reporting total_cost in the API response.
Gemini and Codex are CLI providers. Token counts depend on whether the CLI includes usage metadata in its JSON output. Duration is always available since it is measured client-side.
Data Flow
- Provider
spawn()returnsSpawnResultwith optionalusage: UsageInfo src/spawn.tspassesSpawnResult.usageto the callersrc/implement.ts/src/gate.tscallUsageTracker.record(agent, stage, usage)src/commands/run.tscallsprintUsageSummary(tracker)at the end of the run
UsageTracker API
record(agent, stage, usage)— store one entrygetTotalCost()— sum of allcostUsdvaluesgetByAgent()— aggregated stats per agent namegetEntries()— raw entry list
Summary Output
printUsageSummary() displays a table with total cost, duration, token counts, and per-agent breakdown. Always shown at the end of reygent run.
printVerboseUsage() shows every individual invocation with full detail including stage names, duration, turn count, input/output tokens, and cache metadata. Only shown when reygent run --verbose flag is passed.
