With generate set to 2 to 5, the CLI starts that many complete, identical generations at the same moment (Promise.all at aicommits.ts:147-161), so none of them can read the prompt prefix the others are writing to the provider's cache.
- What to change
- Start the first generation, and start the others once its first model request has returned, so the shared system prompt and diff are served from the automatic cache; the models used here have no usable n parameter.
- Why it matters
- Each copy prefills the same instructions and diff at the uncached price.
- How often it happens
- The code shows the problem; how often it happens is assumed. To measure it: how many users set generate above 1
- Estimate
- about 80k prompt tokens per 1,000 calls not served from cache (estimate)
What the estimate assumes
2% of calls are extra copies from generate above 1 (default is 1, config-types.ts:101-110), about 4,000 prompt tokens each, on providers with automatic caching (OpenAI and most OpenAI-compatible hosts); trades a little latency for the saving.