Skip to main content

AI Runs

Power AI Runs shows what your AI agent runs cost. Every mechanic-build attempt in the agent workflow is recorded with its cost, time and tokens, split per agent and per recorded step. This includes failed attempts, fixes and requested cold build tests. Docs repairs performed during a build contribute to its Docs cost; standalone /update-docs requests and other non-build work are not recorded here. Debug reporting is on by default.

AIRuns window reference

Open it from Tools → Power → AI Runs. It needs Unity 2022.2 or newer; on older versions the window isn't available.

The log is .claude/build-mechanic/runs.json in your project's root folder, outside Assets. It is empty until your first run, and it stays on your machine.

When to use it​

  • What did that mechanic cost? Each run shows its total, and how much went to building the mechanic and how much to improving the docs.
  • Is it getting cheaper? The chart shows the trend across runs, for example after a docs change or a model switch.
  • Where does the money go? See which step of which agent was the most expensive.
Per-step costs

/build-mechanic <request> includes a cost report per step at the end of the run. Use --no-debug to suppress the chat report. Step data comes from # STEP: markers in agent commands and can be recorded without debug mode.

Runs​

Each row is one run: Date, Label, Kind (build-mechanic), Outcome, Models (the models the run's agents used, with their effort), Cost and its Build / Docs $ split, Active and Wall time, API and Tools calls, Reads / Writes (operations), New ctx (new context tokens), Cache rd / Cache wr, Out / Tool out, Gaps (rounds where the builder reported a docs gap), Cold tests, Fixes (your corrections), Debug and the Docs version the run used.

ControlDoes
Kind filterShows all recorded mechanic builds or filters to build-mechanic.
ChartThe metric the chart plots per run: cost, active minutes, API/tool calls, new context, cache reads/writes, output, tool output, or read/write operations. Bars are split into build and docs work.
SearchFilters runs by label, request and notes.
ReloadReads the log again. The window also reloads when you focus it after a new run.
Show JSONShows runs.json in your file browser.

A run's details​

Select a run to see its request, outcome and notes, which model and effort each agent ran on, and its Agents: role, model, cost and share of the run, active time, API calls, cost per call and context sizes. Select an agent to see its Steps: the step name, calls, time, tokens, cost, share of the agent's cost and the power.py commands it ran.

Ctrl/Cmd-click two runs to compare them: the cost, the builder's cost, active time and more are shown side by side with the change in percent, above the details.

How costs are measured​

Each API call is priced per model from AiFlow/build-mechanic/prices.json. Captured usage supplies input, cache and output token counts where available. Claude transcript output can be incomplete because replies are logged before they finish and thinking is hidden; the recorder estimates that missing output. Codex can use captured telemetry or local session usage, and supplied fallback counts remain estimates. These are API-equivalent cost estimates, not subscription charges. A run's details say which of these the output came from:

OutputWhenHow exact
Exact, telemetry / captured sessionClaude telemetry matched the call, or Codex supplied captured telemetry or local session usage.Captured token counts, thinking/reasoning included. Local Codex usage is recorded with usage_origin: session.
EstimatedClaude output could not be matched to telemetry, or explicit fallback counts were supplied for inaccessible Codex usage.Claude: visible output plus estimated thinking. Codex fallback: supplied model/token estimates with their basis in the notes.
MixedTelemetry covered only part of the run.Exact where it could be matched, estimated for the rest.
UnavailableUsage is missing or a model has no configured price.Shown as unavailable, excluded from priced totals; never a free run.
Lower boundRuns recorded before this was added.Thinking not counted.

Turn on exact costs​

  1. Add Claude Code's telemetry settings to .claude/settings.local.json in your project folder. Use the folder you start Claude Code from: the project root, or Assets if you open it there.

    {
    "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4318",
    "OTEL_LOGS_EXPORT_INTERVAL": "2000"
    }
    }
  2. Start the receiver in a terminal from your project root, and keep it running while you work:

    python3 Assets/Plugins/Power/Editor/AiFlow/build-mechanic/otel_receiver.py

    It needs only Python and listens on your machine only. It saves each API call's token counts to .claude/build-mechanic/otel.jsonl, with no prompts or code.

  3. Start a new Claude Code session. The settings are read when a session starts, so a session that is already open isn't measured.

Runs from then on show Exact, telemetry. When the receiver isn't running, Claude Code works as usual and the run is estimated.

Measure Codex runs​

The recorder first tries captured Codex telemetry, then local rollout usage under ~/.codex/sessions (or $CODEX_HOME/sessions). You do not need to turn on telemetry to recover a run whose local usage is available. It merges resumed files for the same conversation, deduplicates response and tool IDs, and excludes inherited parent usage in forks.

After the run, record the conversation with source: "codex". Bound each agent entry to this request, including the final response, and preserve the run ID when recording a later correction:

{
"id": "build-mechanic-my-upgrade",
"kind": "build-mechanic",
"label": "My upgrade",
"request": "The mechanic request",
"outcome": "DONE",
"agents": [{
"id": "<conversation-id>",
"source": "codex",
"role": "mechanic-builder",
"started_at": "2026-10-24T09:00:00Z",
"ended_at": "2026-10-24T09:10:00Z"
}]
}
python3 Assets/Plugins/Power/Editor/AiFlow/build-mechanic/agent_usage.py record meta.json

Verify the saved model and effort, calls, STEP metrics, operations and time. Effort comes from captured turn context. Idle gaps before user prompts are excluded from active time. Individual calls use prices.json, including a model's long-context rates above 272K input tokens when configured.

If neither telemetry nor local usage is accessible, supply estimated_usage on the agent with model, input_token_count, cached_token_count, output_token_count and reasoning_token_count. Output already includes reasoning. Include the captured effort in the agent metadata and explain the count estimate in the run notes. Missing usage or unknown prices must stay unavailable.

For work you want charged separately, use exact STEP names in include_steps on its agent and exclude_steps on the mechanic agent, with the same request bounds. Verify their calls and tokens form a disjoint partition of the full request.

Optional live Codex telemetry uses the same receiver. Configure it in ~/.codex/config.toml and keep otel_receiver.py running:

[otel]
exporter = { otlp-http = { endpoint = "http://127.0.0.1:4318/v1/logs", protocol = "json" } }

agent_usage.py codex lists captured telemetry conversations; agent_usage.py codex <conversation-id> reports one conversation, falling back to local usage when needed.

Make the estimate closer​

The estimate counts thinking with a fixed ratio until it is calibrated. After one run with telemetry on, fit the ratio to it:

python3 Assets/Plugins/Power/Editor/AiFlow/build-mechanic/agent_usage.py calibrate <agent-id> [<agent-id> ...]

The ratio is saved in .claude/build-mechanic/estimates.json and used for every later estimate, so runs without telemetry are closer to their real cost.

note

Prices change. Keep prices.json up to date with your provider's rates (it lists Anthropic and OpenAI models); a model it cannot price is marked unavailable and excluded from priced totals.

Recording scope​

AI Runs records mechanic builds, not account-wide usage limits. Hourly and weekly percentage bars are not part of the current window. Use the chart metric and build/docs split to compare the work recorded for each request.

A later correction updates the same run ID and increases its correction count. Requested cold build tests are separate mechanic-build runs. Preserve every participating agent, including the coordinator; unavailable usage remains marked unavailable rather than becoming a zero-cost run.