Sunny Code

Reducing AI Coding Token Usage: SunnyCode vs Codex

How can you reduce token usage in AI coding? Alongside model choice, compare agents using the same model. We ran the same tasks with shared acceptance criteria to measure token usage, estimated cost, and task performance, then examined the run records to understand the differences.

We held the model at GPT-6 Astra with medium reasoning and Fast off, comparing Codex, SunnyCode Base, and CodeMode on eight tasks across three open-source repositories. Each setup ran every task three times, for 72 runs, with shared primary acceptance criteria and failed runs retained.

In this experiment, CodeMode used 77.2% fewer tokens on average than Codex. Both SunnyCode Base and CodeMode passed 23/24 primary checks; Codex passed 21/24. Failed runs are included, and the results describe complete configurations on these tasks.

At the same frozen rates, CodeMode averaged $0.669 per run versus $1.440 for Codex: 53.5% lower. SunnyCode Base averaged $0.785, 45.5% lower than Codex.

Costs are API-equivalent estimates, not ChatGPT OAuth bills. Runs that failed acceptance remain included.

Mean estimated cost per runUSD
Codex$1.440
SunnyCode Base$0.785
SunnyCode CodeMode$0.669
$0$0.8$1.6
Same frozen rates, all scored runs included. CodeMode is 53.5% lower than Codex; Base is 45.5% lower.

Experiment data was collected on October 14, 2026. Tasks came from p-queue, Click, and markdown-it, covering async queues, command-line interfaces, and Markdown parsing: five authored feature requests, one authored bug task, and two upstream bugs.

How the experiment worked

Each run used GPT-6 Astra, medium reasoning, Fast off, a fresh session, and a prepared checkout. Every task ran three times per setup. Frozen behavior checks and repository tests ran independently afterward; their time is excluded from completion time. This compares complete setups with different system prompts.

SetupEst. cost (USD)Mean tokensPassed / totalMean time (s)
Codex$1.440725,18521/24222.6
SunnyCode Base$0.785281,08023/24297.1
SunnyCode CodeMode$0.669165,56623/24232.2

Where the token gap comes from

The largest recorded difference is input context. Cached input accounts for 96.5% of Codex’s additional tokens versus CodeMode. At the frozen rates, 70.0% of the estimated cost gap comes from cached input, 24.6% from uncached input, and 5.4% from output. This decomposition explains the accounting; it does not isolate the causal effect of a product design choice.

That is why token savings and cost savings differ. CodeMode used 77.2% fewer tokens on average, with 53.5% lower estimated cost. Cached input is discounted, but repeated context still adds up.

Mean token composition24 runs per mode
Cached inputUncached inputOutput
Codex725.2k
SunnyCode Base281.1k
SunnyCode CodeMode165.6k
0400k800k
Cached input is context reported as a cache hit. It still contributes to total tokens; this is not a measure of generated code or output length.
Inspect exact token components
SetupCached inputUncached inputOutput
Codex670,93948,5745,672
SunnyCode Base246,94429,2214,915
SunnyCode CodeMode131,09929,6354,833

Results by task type

For feature work, both SunnyCode modes passed 14/15 primary checks, versus 12/15 for Codex. All three setups passed every bug-fix run. The chart shows mean recorded tokens per run, including failed runs.

SetupMean tokensAcceptance

Feature work · 5 tasks

Codex
839.3k
12/1580%
SunnyCode Base
342.5k
14/1593.3%
SunnyCode CodeMode
201.6k
14/1593.3%

Authored bug · 1 task

Codex
890.7k
3/3100%
SunnyCode Base
300.9k
3/3100%
SunnyCode CodeMode
161.5k
3/3100%

Upstream bugs · 2 tasks

Codex
357.2k
6/6100%
SunnyCode Base
117.5k
6/6100%
SunnyCode CodeMode
77.6k
6/6100%
0500k1M
All categories share a 0–1M token scale. Means include every run, including failures. Acceptance shows passed / total runs and the pass rate.
Inspect exact values by task type
SetupMean tokensPassed / total
Feature work · 5 tasks
Codex839,27912/15
SunnyCode Base342,53914/15
SunnyCode CodeMode201,55214/15
Authored bug · 1 task
Codex890,7093/3
SunnyCode Base300,8963/3
SunnyCode CodeMode161,5323/3
Upstream bugs · 2 tasks
Codex357,1876/6
SunnyCode Base117,5246/6
SunnyCode CodeMode77,6206/6

Fewer tokens did not always mean less time

From submission to the saved final response, Codex averaged 222.6 seconds, CodeMode 232.2, and SunnyCode Base 297.1. Comparing three-run means for each task, Codex was slower than CodeMode on six of eight tasks. Faster results on D and H lowered its overall mean. Accumulated cached-input tokens do not directly predict generation time.

Applying the comparison to your own workflow

To compare agents, hold the model, reasoning level, tasks, and acceptance criteria constant. Record uncached input, cached input, and output tokens separately, retaining both successful and failed runs, and compare cost alongside completion time. These results make agent choice worth evaluating for token efficiency; they do not guarantee the same savings in your repository.

Limitations and unsuccessful checks

These are 72 runs on eight tasks, not a general quality ranking. Base was collected later; provider conditions, caches, and host load were not randomized. Half the tasks came from p-queue. Costs are API-equivalent estimates at frozen rates, not ChatGPT OAuth bills.

Supplemental checks retain the CodeMode C3 string-Iterable defect and the Codex C1 timing-sensitive failure. Pass rates use the original primary acceptance checks; they do not establish an absence of other defects.

Cost and timing definitions

These records use frozen rates of $10 per million uncached input tokens, $1 per million cached input tokens, and $50 per million output tokens. This is the historical estimation basis, not a statement of current prices. Timing starts before submission or dispatch and ends when the final assistant response is saved; independent grading is excluded.

Task and repository key
TaskRepositoryDescription
Ap-queueBatch settled results
Bp-queueQueue notification timing
Cp-queueBounded streaming mapper
Dp-queueGraceful queue shutdown
EClickEnvironment-variable hints
FClickCanonical choice aliases
Gmarkdown-itReference-definition boundaries
Hmarkdown-itStable heading IDs
Inspect the individual runs
TaskSetupRepeatUSDTokensPassed / total
ASunnyCode Base10.7422241,335Passed
ASunnyCode CodeMode10.445592,950Passed
ACodex12.02361,183,932Failed
ASunnyCode Base20.7598241,086Passed
ASunnyCode CodeMode20.4498112,613Failed
ACodex21.2592641,490Failed
ASunnyCode Base30.8306272,997Passed
ASunnyCode CodeMode30.502172,994Passed
ACodex31.87601,079,699Passed
BSunnyCode Base11.0518419,721Passed
BSunnyCode CodeMode10.8774194,948Passed
BCodex11.68531,003,710Passed
BSunnyCode Base20.7902239,038Passed
BSunnyCode CodeMode20.5975145,752Passed
BCodex21.7201915,126Passed
BSunnyCode Base30.6769243,929Passed
BSunnyCode CodeMode30.5574143,897Passed
BCodex31.5795753,290Passed
CSunnyCode Base12.12191,085,571Passed
CSunnyCode CodeMode11.3020297,815Passed
CCodex12.65951,296,542Failed
CSunnyCode Base21.6082581,955Passed
CSunnyCode CodeMode21.3187402,219Passed
CCodex22.74191,411,174Passed
CSunnyCode Base31.9456730,566Passed
CSunnyCode CodeMode31.1199359,949Passed
CCodex32.98401,650,733Passed
DSunnyCode Base10.396459,718Failed
DSunnyCode CodeMode10.8586262,300Passed
DCodex11.9833951,994Passed
DSunnyCode Base21.1001379,470Passed
DSunnyCode CodeMode20.8817221,190Passed
DCodex21.9592979,874Passed
DSunnyCode Base30.9450385,236Passed
DSunnyCode CodeMode30.8979200,180Passed
DCodex31.7191984,987Passed
ESunnyCode Base10.330883,423Passed
ESunnyCode CodeMode10.268258,949Passed
ECodex10.5933308,106Passed
ESunnyCode Base20.277093,615Passed
ESunnyCode CodeMode20.251760,291Passed
ECodex20.7865301,274Passed
ESunnyCode Base30.218675,385Passed
ESunnyCode CodeMode30.316047,991Passed
ECodex30.5671266,115Passed
FSunnyCode Base10.4657145,082Passed
FSunnyCode CodeMode10.4876102,247Passed
FCodex10.9280330,546Passed
FSunnyCode Base20.4528152,009Passed
FSunnyCode CodeMode20.451869,422Passed
FCodex20.9449357,906Passed
FSunnyCode Base30.5927154,713Passed
FSunnyCode CodeMode30.5732120,528Passed
FCodex30.8337402,871Passed
GSunnyCode Base10.5377147,887Passed
GSunnyCode CodeMode10.4625103,883Passed
GCodex10.9944406,652Passed
GSunnyCode Base20.5251186,508Passed
GSunnyCode CodeMode20.5367109,540Passed
GCodex20.7919413,342Passed
GSunnyCode Base30.3804118,326Passed
GSunnyCode CodeMode30.399285,068Passed
GCodex31.0203447,635Passed
HSunnyCode Base10.6913278,151Passed
HSunnyCode CodeMode10.7128193,728Passed
HCodex11.0902426,294Passed
HSunnyCode Base20.7703244,969Passed
HSunnyCode CodeMode20.8946271,301Passed
HCodex20.9651480,409Passed
HSunnyCode Base30.6261185,223Passed
HSunnyCode CodeMode30.8956243,840Passed
HCodex30.8604410,728Passed