You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Audit of ~/.pilot/data/pilot.db for Apr 17–27 shows 110 of 168 executions (65%) record tokens_total=0 and estimated_cost_usd=0, including 94 completed runs with valid commit_sha / pr_url. Real work, no usage data.
These 0-token rows also have empty model_name, suggesting the SDK message stream never produced a result event with token usage that runner.go could parse.
Likely root cause
Pilot now runs alternate backends (OpenCode → GLM/Z.AI per recent commits like 0bc54c6f fix(executor): send OpenCode model as {providerID, modelID}). The token-aggregation code paths in internal/executor/runner.go (lines 1642, 1942, 2010, 2148, 2487, 2687) appear tied to the Claude-Code SDK message format. If the OpenCode adapter doesn't emit equivalent usage events — or emits them in a different shape — state.tokensInput/tokensOutput stay at 0 and SaveExecutionMetrics writes zeros.
Cost reporting (bench-status.py, dashboard, lifetime tokens via fix(dashboard): metrics cards show inconsistent data across restarts #533) understates actual spend. Recorded $104.85 vs. account-level ccusage $574 over the same window — Pilot looks like 18% of spend when actual share is much higher.
Pattern-learning model-outcome scoring uses estimated_cost_usd for cost-per-PR — biased toward backends that don't report.
Budget enforcement (gateway/budget.go) can't enforce per-task limits on backends with no token telemetry.
Suggested fix
Audit internal/executor/runner.go token-capture sites against each backend (Claude Code SDK, OpenCode, Codex). Confirm where state.tokensInput/Output and cacheCreationInputTokens are set per backend.
For OpenCode/GLM: parse the backend's usage event format and map to state.tokens* fields. If the backend doesn't emit usage, tokenize the prompt + output locally as a fallback estimate (mark as estimated).
Set result.ModelName even when token usage is missing, so we can filter "telemetry-missing" runs from "true-zero" runs.
Add a startup check: if last N completed executions all have tokens_total=0 for a given backend, log a warning.
Verification
After fix: rerun a known issue against each backend, confirm tokens_total > 0 and model_name != '' for all completed executions. Backfill not required.
Problem
Audit of
~/.pilot/data/pilot.dbfor Apr 17–27 shows 110 of 168 executions (65%) recordtokens_total=0andestimated_cost_usd=0, including 94 completed runs with validcommit_sha/pr_url. Real work, no usage data.These 0-token rows also have empty
model_name, suggesting the SDK message stream never produced aresultevent with token usage thatrunner.gocould parse.Likely root cause
Pilot now runs alternate backends (OpenCode → GLM/Z.AI per recent commits like
0bc54c6f fix(executor): send OpenCode model as {providerID, modelID}). The token-aggregation code paths ininternal/executor/runner.go(lines 1642, 1942, 2010, 2148, 2487, 2687) appear tied to the Claude-Code SDK message format. If the OpenCode adapter doesn't emit equivalent usage events — or emits them in a different shape —state.tokensInput/tokensOutputstay at 0 andSaveExecutionMetricswrites zeros.Sample affected runs (real work, 0 tokens):
Why it matters
bench-status.py, dashboard, lifetime tokens via fix(dashboard): metrics cards show inconsistent data across restarts #533) understates actual spend. Recorded $104.85 vs. account-level ccusage $574 over the same window — Pilot looks like 18% of spend when actual share is much higher.estimated_cost_usdfor cost-per-PR — biased toward backends that don't report.gateway/budget.go) can't enforce per-task limits on backends with no token telemetry.Suggested fix
internal/executor/runner.gotoken-capture sites against each backend (Claude Code SDK, OpenCode, Codex). Confirm wherestate.tokensInput/OutputandcacheCreationInputTokensare set per backend.state.tokens*fields. If the backend doesn't emit usage, tokenize the prompt + output locally as a fallback estimate (mark asestimated).result.ModelNameeven when token usage is missing, so we can filter "telemetry-missing" runs from "true-zero" runs.tokens_total=0for a given backend, log a warning.Verification
After fix: rerun a known issue against each backend, confirm
tokens_total > 0andmodel_name != ''for all completed executions. Backfill not required.Refs
internal/executor/runner.go:1642,1942,2010,2148,2487,2687internal/executor/dispatcher.go:670(SaveExecutionMetrics call site)internal/memory/metrics.go:1690bc54c6f(OpenCode model object fix)