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.
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.
| Setup | Est. cost (USD) | Mean tokens | Passed / total | Mean time (s) |
|---|---|---|---|---|
| Codex | $1.440 | 725,185 | 21/24 | 222.6 |
| SunnyCode Base | $0.785 | 281,080 | 23/24 | 297.1 |
| SunnyCode CodeMode | $0.669 | 165,566 | 23/24 | 232.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.
Inspect exact token components
| Setup | Cached input | Uncached input | Output |
|---|---|---|---|
| Codex | 670,939 | 48,574 | 5,672 |
| SunnyCode Base | 246,944 | 29,221 | 4,915 |
| SunnyCode CodeMode | 131,099 | 29,635 | 4,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.
Feature work · 5 tasks
Authored bug · 1 task
Upstream bugs · 2 tasks
Inspect exact values by task type
| Setup | Mean tokens | Passed / total |
|---|---|---|
| Feature work · 5 tasks | ||
| Codex | 839,279 | 12/15 |
| SunnyCode Base | 342,539 | 14/15 |
| SunnyCode CodeMode | 201,552 | 14/15 |
| Authored bug · 1 task | ||
| Codex | 890,709 | 3/3 |
| SunnyCode Base | 300,896 | 3/3 |
| SunnyCode CodeMode | 161,532 | 3/3 |
| Upstream bugs · 2 tasks | ||
| Codex | 357,187 | 6/6 |
| SunnyCode Base | 117,524 | 6/6 |
| SunnyCode CodeMode | 77,620 | 6/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
| Task | Repository | Description |
|---|---|---|
| A | p-queue | Batch settled results |
| B | p-queue | Queue notification timing |
| C | p-queue | Bounded streaming mapper |
| D | p-queue | Graceful queue shutdown |
| E | Click | Environment-variable hints |
| F | Click | Canonical choice aliases |
| G | markdown-it | Reference-definition boundaries |
| H | markdown-it | Stable heading IDs |
Inspect the individual runs
| Task | Setup | Repeat | USD | Tokens | Passed / total |
|---|---|---|---|---|---|
| A | SunnyCode Base | 1 | 0.7422 | 241,335 | Passed |
| A | SunnyCode CodeMode | 1 | 0.4455 | 92,950 | Passed |
| A | Codex | 1 | 2.0236 | 1,183,932 | Failed |
| A | SunnyCode Base | 2 | 0.7598 | 241,086 | Passed |
| A | SunnyCode CodeMode | 2 | 0.4498 | 112,613 | Failed |
| A | Codex | 2 | 1.2592 | 641,490 | Failed |
| A | SunnyCode Base | 3 | 0.8306 | 272,997 | Passed |
| A | SunnyCode CodeMode | 3 | 0.5021 | 72,994 | Passed |
| A | Codex | 3 | 1.8760 | 1,079,699 | Passed |
| B | SunnyCode Base | 1 | 1.0518 | 419,721 | Passed |
| B | SunnyCode CodeMode | 1 | 0.8774 | 194,948 | Passed |
| B | Codex | 1 | 1.6853 | 1,003,710 | Passed |
| B | SunnyCode Base | 2 | 0.7902 | 239,038 | Passed |
| B | SunnyCode CodeMode | 2 | 0.5975 | 145,752 | Passed |
| B | Codex | 2 | 1.7201 | 915,126 | Passed |
| B | SunnyCode Base | 3 | 0.6769 | 243,929 | Passed |
| B | SunnyCode CodeMode | 3 | 0.5574 | 143,897 | Passed |
| B | Codex | 3 | 1.5795 | 753,290 | Passed |
| C | SunnyCode Base | 1 | 2.1219 | 1,085,571 | Passed |
| C | SunnyCode CodeMode | 1 | 1.3020 | 297,815 | Passed |
| C | Codex | 1 | 2.6595 | 1,296,542 | Failed |
| C | SunnyCode Base | 2 | 1.6082 | 581,955 | Passed |
| C | SunnyCode CodeMode | 2 | 1.3187 | 402,219 | Passed |
| C | Codex | 2 | 2.7419 | 1,411,174 | Passed |
| C | SunnyCode Base | 3 | 1.9456 | 730,566 | Passed |
| C | SunnyCode CodeMode | 3 | 1.1199 | 359,949 | Passed |
| C | Codex | 3 | 2.9840 | 1,650,733 | Passed |
| D | SunnyCode Base | 1 | 0.3964 | 59,718 | Failed |
| D | SunnyCode CodeMode | 1 | 0.8586 | 262,300 | Passed |
| D | Codex | 1 | 1.9833 | 951,994 | Passed |
| D | SunnyCode Base | 2 | 1.1001 | 379,470 | Passed |
| D | SunnyCode CodeMode | 2 | 0.8817 | 221,190 | Passed |
| D | Codex | 2 | 1.9592 | 979,874 | Passed |
| D | SunnyCode Base | 3 | 0.9450 | 385,236 | Passed |
| D | SunnyCode CodeMode | 3 | 0.8979 | 200,180 | Passed |
| D | Codex | 3 | 1.7191 | 984,987 | Passed |
| E | SunnyCode Base | 1 | 0.3308 | 83,423 | Passed |
| E | SunnyCode CodeMode | 1 | 0.2682 | 58,949 | Passed |
| E | Codex | 1 | 0.5933 | 308,106 | Passed |
| E | SunnyCode Base | 2 | 0.2770 | 93,615 | Passed |
| E | SunnyCode CodeMode | 2 | 0.2517 | 60,291 | Passed |
| E | Codex | 2 | 0.7865 | 301,274 | Passed |
| E | SunnyCode Base | 3 | 0.2186 | 75,385 | Passed |
| E | SunnyCode CodeMode | 3 | 0.3160 | 47,991 | Passed |
| E | Codex | 3 | 0.5671 | 266,115 | Passed |
| F | SunnyCode Base | 1 | 0.4657 | 145,082 | Passed |
| F | SunnyCode CodeMode | 1 | 0.4876 | 102,247 | Passed |
| F | Codex | 1 | 0.9280 | 330,546 | Passed |
| F | SunnyCode Base | 2 | 0.4528 | 152,009 | Passed |
| F | SunnyCode CodeMode | 2 | 0.4518 | 69,422 | Passed |
| F | Codex | 2 | 0.9449 | 357,906 | Passed |
| F | SunnyCode Base | 3 | 0.5927 | 154,713 | Passed |
| F | SunnyCode CodeMode | 3 | 0.5732 | 120,528 | Passed |
| F | Codex | 3 | 0.8337 | 402,871 | Passed |
| G | SunnyCode Base | 1 | 0.5377 | 147,887 | Passed |
| G | SunnyCode CodeMode | 1 | 0.4625 | 103,883 | Passed |
| G | Codex | 1 | 0.9944 | 406,652 | Passed |
| G | SunnyCode Base | 2 | 0.5251 | 186,508 | Passed |
| G | SunnyCode CodeMode | 2 | 0.5367 | 109,540 | Passed |
| G | Codex | 2 | 0.7919 | 413,342 | Passed |
| G | SunnyCode Base | 3 | 0.3804 | 118,326 | Passed |
| G | SunnyCode CodeMode | 3 | 0.3992 | 85,068 | Passed |
| G | Codex | 3 | 1.0203 | 447,635 | Passed |
| H | SunnyCode Base | 1 | 0.6913 | 278,151 | Passed |
| H | SunnyCode CodeMode | 1 | 0.7128 | 193,728 | Passed |
| H | Codex | 1 | 1.0902 | 426,294 | Passed |
| H | SunnyCode Base | 2 | 0.7703 | 244,969 | Passed |
| H | SunnyCode CodeMode | 2 | 0.8946 | 271,301 | Passed |
| H | Codex | 2 | 0.9651 | 480,409 | Passed |
| H | SunnyCode Base | 3 | 0.6261 | 185,223 | Passed |
| H | SunnyCode CodeMode | 3 | 0.8956 | 243,840 | Passed |
| H | Codex | 3 | 0.8604 | 410,728 | Passed |