downshift cost report

Building Downshift in Alan

opencode · ~/.alan/alan-code/engine/share/opencode/opencode.db

Total cost
$0.6009
Tokens
26,863,020
Steps
194
Model
deepseek/deepseek-v4.1-flash
Read + search + test
27.1% of spend

Cost flamegraph

Width is recomputed cost. Hover a block for its numbers, click it to zoom in, click the top row or press Esc to zoom back out. Pick a kind below to highlight it.

sessionphasekindstep Building Downshift in Alan · $0.6009 · 26,863,020 tokensBuilding Downshift in Alan implement · $0.4135 · 17,145,123 tokensimplement explore · $0.1002 · 5,018,460 tokensexplore verify · $0.0625 · 3,294,426 tokensverify plan · $0.0247 · 1,405,011 tokens shell · $0.2173 · 10,893,918 tokensshell edit · $0.1962 · 6,251,205 tokensedit search · $0.0748 · 3,411,024 tokenssearch read · $0.0254 · 1,607,436 tokens test · $0.0625 · 3,294,426 tokenstest plan · $0.0247 · 1,405,011 tokens python3 - <<'PY' from pathlib import Path p=Path("src/cli.ts") s=p.read_text() … · $0.0261 · 1,309,566 tokens npx tsx src/cli.ts analyze latest:alan 2>&1 · $0.0197 · 1,170,309 tokens node -e "console.log(require('openai/package.json').version)" · $0.0124 · 214,259 tokens python3 - <<'PY' from pathlib import Path p=Path("src/flame/speedscope.ts") s=p… · $0.0117 · 507,131 tokens python3 - <<'PY' from pathlib import Path p=Path("src/providers/index.ts") s=p.… · $0.0114 · 491,716 tokens python3 - <<'PY' from pathlib import Path p=Path("src/report/html.ts") s=p.read… · $0.0103 · 592,858 tokens npx tsx -e " import { resolveTarget } from './src/ingest/discover.ts'; import {… · $0.008305 · 501,840 tokens python3 - <<'PY' from pathlib import Path p=Path("src/replay/run.ts") s=p.read_… · $0.006225 · 273,688 tokens python3 - <<'PY' from pathlib import Path p=Path("src/classify/kinds.ts") s=p.r… · $0.005313 · 139,263 tokens python3 - <<'PY' from pathlib import Path p=Path("src/types.ts") s=p.read_text(… · $0.005054 · 242,011 tokens npx tsx src/cli.ts replay latest --per-kind 2 2>&1 · $0.004836 · 277,736 tokens node -e " const r=require('./downshift-report/replays.json'); console.log('reco… · $0.004455 · 278,624 tokens npx tsx src/cli.ts replay latest --per-kind 1 --models ollama:gemma4:latest 2>&1 · $0.004444 · 275,472 tokens git add src/types.ts src/ingest/claude-code.ts src/ingest/opencode.ts src/repla… · $0.004440 · 252,352 tokens node -e " const r=require('./downshift-report/replays.json'); console.log({sess… · $0.004325 · 276,282 tokens git add src/providers/index.ts test/providers.test.ts test/pricing.test.ts · $0.004095 · 262,501 tokens git push origin main 2>&1 · $0.003846 · 242,589 tokens git add DEVLOG.md src/cli.ts src/providers/index.ts src/providers/doctor.ts tes… · $0.003677 · 226,286 tokens python3 - <<'PY' from pathlib import Path p=Path("src/ingest/discover.ts") s=p.… · $0.003651 · 139,345 tokens npx tsx src/cli.ts doctor 2>&1 · $0.003529 · 223,744 tokens npx tsx src/cli.ts analyze latest:alan --title "Alan Code cost demo" 2>&1 · $0.003433 · 202,673 tokens git add DEVLOG.md src/cli.ts src/report/html.ts test/html.test.ts · $0.003338 · 203,999 tokens python3 - <<'PY' from pathlib import Path p=Path("test/classify.test.ts") s=p.r… · $0.003241 · 118,861 tokens git add DEVLOG.md src/cli.ts src/flame/speedscope.ts src/report/html.ts test/ht… · $0.003080 · 185,512 tokens python3 - <<'PY' from pathlib import Path p=Path("test/claude-code.test.ts") s=… · $0.003027 · 73,193 tokens git add src/paths.ts src/flame/speedscope.ts src/cli.ts test/paths.test.ts test… · $0.002757 · 167,531 tokens node --experimental-strip-types -e "1" 2>/dev/null · $0.002690 · 155,921 tokens python3 - <<'PY' from pathlib import Path p=Path("DEVLOG.md") s=p.read_text() o… · $0.002596 · 130,528 tokens git add DEVLOG.md src/cli.ts src/flame/speedscope.ts test/flame.test.ts · $0.002551 · 157,941 tokens git add src/classify/kinds.ts test/classify.test.ts · $0.002355 · 141,292 tokens echo "---" · $0.002266 · 119,304 tokens git add DEVLOG.md src/classify/kinds.ts src/cli.ts test/classify.test.ts · $0.002135 · 131,728 tokens curl -s --max-time 25 https://openrouter.ai/api/v1/models · $0.001779 · 78,680 tokens git add DEVLOG.md src/cli.ts src/ingest/claude-code.ts src/ingest/discover.ts t… · $0.001714 · 77,494 tokens npx tsx src/cli.ts analyze latest:claude-code 2>&1 · $0.001710 · 96,587 tokens cut -c1-900 · $0.001674 · 62,119 tokens node -v · $0.001674 · 29,752 tokens git add DEVLOG.md README.md src/cli.ts src/classify/kinds.ts src/pricing/model-… · $0.001642 · 98,757 tokens npm view vitest@3 version · $0.001609 · 59,457 tokens node -e "const m=require('module'); console.log(m.isBuiltin('node:sqlite'), m.i… · $0.001439 · 49,555 tokens echo "===CLI===" · $0.001380 · 75,201 tokens npx tsx src/cli.ts analyze latest 2>&1 · $0.001356 · 62,475 tokens cut -c1-1500 · $0.001339 · 59,793 tokens npx tsx src/cli.ts sessions 2>&1 · $0.001317 · 75,001 tokens npm run build 2>&1 · $0.001231 · 65,427 tokens echo "=====DISCOVER=====" · $0.001207 · 53,040 tokens git add DEVLOG.md package.json package-lock.json src/cli.ts src/ingest/opencode… · $0.001155 · 65,751 tokens perl -0pi -e 's/import \{ existsSync, readdirSync, readFileSync, statSync \} fr… · $0.001025 · 43,607 tokens npm install -D vitest@^3.2.7 2>&1 · $0.000994 · 59,632 tokens node -e "const {builtinModules}=require('module'); console.log(builtinModules.f… · $0.000886 · 51,621 tokens xxd · $0.000825 · 43,914 tokens time npx tsx src/cli.ts replay latest --per-kind 2 2>&1 · $0.00 · 0 tokens edit > · $0.0237 · 1,136,273 tokens edit src/flame/speedscope.ts · $0.0116 · 150,863 tokens edit /tmp/or-models.json · $0.0110 · 341,825 tokens edit src/ingest/opencode.ts · $0.0107 · 38,812 tokens edit src/report/html.ts · $0.0101 · 178,547 tokens edit src/classify/kinds.ts · $0.009394 · 206,440 tokens edit src/ingest/claude-code.ts · $0.008172 · 329,088 tokens edit src/replay/run.ts · $0.007985 · 271,543 tokens edit test/replay.test.ts · $0.007191 · 249,836 tokens edit src/providers/index.ts · $0.006942 · 218,447 tokens edit src/pricing/openrouter.ts · $0.006756 · 85,811 tokens edit ( · $0.006528 · 195,055 tokens edit src/replay/context.ts · $0.006165 · 246,339 tokens edit src/replay/tools.ts · $0.005424 · 243,828 tokens edit src/providers/doctor.ts · $0.005391 · 220,556 tokens edit vitest.config.ts · $0.005326 · 222,703 tokens edit test/providers.test.ts · $0.005037 · 223,255 tokens edit test/flame.test.ts · $0.004998 · 154,792 tokens edit { · $0.004994 · 201,568 tokens edit test/html.test.ts · $0.004863 · 182,707 tokens edit src/replay/sampler.ts · $0.004821 · 267,561 tokens edit src/ingest/discover.ts · $0.004415 · 108,052 tokens edit src/pricing/model-map.ts · $0.004112 · 88,652 tokens edit test/pricing.test.ts · $0.003611 · 93,804 tokens edit test/opencode.test.ts · $0.003377 · 48,536 tokens edit test/paths.test.ts · $0.003265 · 166,301 tokens edit src/paths.ts · $0.002843 · 164,622 tokens edit test/classify.test.ts · $0.002707 · 95,119 tokens edit src/cli.ts · $0.002369 · 45,830 tokens edit test/discover.test.ts · $0.002329 · 74,440 tokens grep "deriveTitle\|firstUserTitle\|readMessageText\|const resolvedSessionId\|ti… · $0.0123 · 239,193 tokens grep "stepFrameName\|bashFrameName\|toolFilePath\|Path" · $0.008065 · 163,694 tokens grep "interface Block\|function buildBlocks\|function renderSvg\|function rende… · $0.007566 · 190,166 tokens grep "ChatCompletionToolChoiceOption" · $0.004104 · 262,744 tokens ls node_modules/openai/resources/chat* 2>/dev/null · $0.004041 · 262,941 tokens grep "ToolChoice\|tool_choice" · $0.004029 · 263,169 tokens grep "ToolChoice" · $0.004018 · 262,831 tokens grep "-m1" · $0.003374 · 214,685 tokens grep ".\{60\}https\?://.\{40\}" · $0.002929 · 184,000 tokens git log --oneline -4 · $0.002880 · 185,699 tokens grep "command(\" · $0.002865 · 178,708 tokens git status --short · $0.002437 · 108,523 tokens git log --oneline -3 · $0.002151 · 132,958 tokens git diff --stat · $0.002041 · 130,684 tokens grep "Failed to load url" · $0.001396 · 52,351 tokens grep "isNodeBuiltin\|externalize" · $0.001343 · 57,004 tokens git diff -- vitest.config.ts · $0.001118 · 65,040 tokens grep ""type":"custom-title"[^}]*" · $0.001081 · 58,811 tokens grep "normalizeTitle\|readClaudeMetadata\|title: metadata" · $0.001074 · 66,691 tokens git diff -- vitest.config.ts package.json src/cli.ts · $0.001064 · 63,978 tokens grep "prefixedBuiltins\|builtins\|sqlite\|node:" · $0.001033 · 59,837 tokens grep "isBuiltin\|builtinModules" · $0.001001 · 53,433 tokens grep "nodeBuiltins.includes\|nodeBuiltins\b" · $0.000926 · 52,562 tokens grep "isBuiltin" · $0.000915 · 50,959 tokens grep "class DatabaseSync\|interface DatabaseSyncOptions\|readOnly\|prepare(\|al… · $0.000540 · 30,111 tokens ls -la · $0.000494 · 20,252 tokens read src/report/html.ts · $0.0121 · 779,461 tokens read src/ingest/claude-code.ts · $0.003760 · 239,512 tokens read src/cli.ts · $0.003191 · 200,561 tokens read test/classify.test.ts · $0.002253 · 140,847 tokens read src/ingest/discover.ts · $0.002251 · 135,654 tokens read node_modules/vite-node/dist/server.mjs · $0.000952 · 57,560 tokens read node_modules/vite-node/dist/utils.mjs · $0.000877 · 53,841 tokens npm test 2>&1 · $0.0203 · 1,240,150 tokens python3 - <<'PY' from pathlib import Path p=Path("src/classify/kinds.ts") s=p.r… · $0.009477 · 387,968 tokens npm run typecheck 2>&1 · $0.008995 · 421,154 tokens python3 - <<'PY' from pathlib import Path p=Path("test/html.test.ts") s=p.read_… · $0.006595 · 385,109 tokens python3 - <<'PY' from pathlib import Path p=Path("test/replay.test.ts") s=p.rea… · $0.005322 · 274,925 tokens python3 - <<'PY' from pathlib import Path p=Path("test/classify.test.ts") s=p.r… · $0.003355 · 140,543 tokens python3 - <<'PY' from pathlib import Path p=Path("src/flame/speedscope.ts") s=p… · $0.003200 · 157,129 tokens python3 - <<'PY' from pathlib import Path p=Path("test/flame.test.ts") s=p.read… · $0.002837 · 166,654 tokens ''' new='''const ENV_ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|'[^']*'|\… · $0.002429 · 120,794 tokens plan · $0.0247 · 1,405,011 tokens

Cost over time

Running total of list-price cost, step by step. The strip below is each step's own cost, coloured by kind. Hover to read a step.

$0.1502$0.3004$0.4506$0.6009 $0 per step step 1 step 194

Spend by step kind

Click a column to sort. Click a row to highlight that kind in the flamegraph.

KindStepsTokensCost% spend
shell7710,893,918$0.217336.2%
edit476,251,205$0.196232.7%
search263,411,024$0.074812.4%
test233,294,426$0.062510.4%
read121,607,436$0.02544.2%
plan91,405,011$0.02474.1%

Replay matrix

Kindgroq:openai/gpt-oss-120bollama:gemma4:latest
read50%25%
search0%0%
edit0%0%
test0%0%
shell0%0%
plan0%0%

Match rate is the share of replayed steps scoring at least 80% against the recorded action.

Projected savings

Before
$0.6009
After
$0.6009
Saved
0.0%
KindRouteStepsBeforeAfter

Projected at list prices — actual spend $0.

Proof

Cheapest passing run: downshift $0.001494 vs big $0.002254, 33.7% cheaper at list price, with the tests passing in both.

Pass rate

big
100%
small
50%
downshift
50%

Mean list price per run

big
$0.002282
small
$0.00
downshift
$0.000747

Escalation rate

big
0%
small
0%
downshift
21%

Every run

ConfigRunResultStepsEscalatedList priceTime
big1pass100$0.0023114.7 min
big2pass100$0.0022545.6 min
small1pass90$0.001.6 min
small2fail: Request timed out.50$0.002.0 min
downshift1pass93$0.0014944.4 min
downshift2fail: Request timed out.50$0.002.2 min

2 runs per config on bench/tasks/csv-export; max 30 steps. Success requires `npm test` to exit 0 with unchanged test files. Means include failed runs.

Actual spend: $0 (local + free tiers).