The same cut-off request is sent up to three times, unchanged

A cream desktop machine feeds out three paper strips side by side while a steel blade cuts every strip off at the same point.

Cut-off answer Reported

A commit-message CLI for twelve providers, with a carefully bounded agentic flow that sees every staged change.

≈ 120,000 tokens per 1,000 calls, for a cut-off answer sent again with the same output limit estimate

Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.

Repository
Nutlope/aicommits
Commit audited
98e9c4e
leanprompt version
0.1.0-dev.15
Audit date
Status
The maintainers have been told about this audit; no response yet.
Maintainers
the issue
How it ran
Unattended audit: nobody was asked during the run, so priority, volume and prices were left open; the questions for the owner are listed at the end.

A commit-message CLI with twelve providers and a carefully bounded agentic flow: diffs segmented so every change is seen, a model-call budget, validated subjects. A cut-off answer is retried with the same limit and a cut-off body can be committed as whole; the other items are small. Figures are estimates from the code.

leanprompt read the code at commit 98e9c4e and found 4 places where its LLM calls could use fewer tokens, 2 the project already knows about, plus 3 other problems, not scored. Static score: 97 of 100 (an estimate from the findings, leaving out what the project already knows about). The code may have changed since.

Findings

  1. LP-GE-01 n samples in one request

    src/commands/aicommits.ts:147 · severity low · saves prefill · how often is assumed

    What happens. 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.

    The 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 helps. Each copy prefills the same instructions and diff at the uncached price.

    Estimate about 80k prompt tokens per 1,000 calls not served from cache (estimate)

    Assumptions. 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.

    How often. how many users set generate above 1

  2. LP-GE-02 Batch independent questions about one context

    src/commands/pr.ts:179 · severity medium · saves prefill and generation · how often is assumed

    What happens. aicommits pr sends the same branch diff (up to 30,000 characters) twice, once to ask for a title (pr.ts:179) and once for a body (pr.ts:189). The two calls start with different system prompts, so even an automatic prefix cache cannot reuse the diff on the second call.

    The change. Ask for the title and the body in one call with a two-field structured output (the agent SDK path already uses JSON schemas, see agent-sdk.ts), or at least keep one identical system prompt and put the question after the diff.

    Why it helps. Each run prefills the diff twice at full price; the diff is about 7,500 tokens at the 30,000-character cap.

    Estimate about 76k prompt tokens per 1,000 calls (estimate)

    Assumptions. pr runs are 2% of calls (10 runs, 20 calls per 1,000), each with a diff near the 30,000-character cap; the answer check (title under 72 characters, body with the three headings) must pass before keeping one call.

    How often. how many runs are aicommits pr (a beta command) rather than commit message runs

  3. LP-GE-05 Retry only retryable errors; never retry a truncation unchanged

    src/commands/aicommits.ts:183 · severity medium · saves prefill and generation · how often is assumed

    What happens. When a generation fails for any reason, the CLI re-runs the whole generation with the provider's fallback model (aicommits.ts:176-202; the Git hook does the same at prepare-commit-msg-hook.ts:90-97). That includes errors a new model cannot fix: 'Claude is not logged in', 'Claude plan limit reached' (claude-agent.ts:84-95) and the shared deadline timing out, where the second run redoes every chunk call with a larger model and a fresh deadline.

    The change. Fall back to another model only for model errors (isModelUnavailableError, or the model producing no usable message); rethrow login, plan-limit and timeout errors directly.

    Why it helps. A re-run after a timeout pays for all the chunk calls again; a re-run after a login or plan error only delays the error.

    Estimate about 20k prompt tokens per 1,000 calls (estimate)

    Assumptions. applies to Together AI, Claude Agent, Codex and OpenCode Go, which define fallbackModel; 0.5% of calls are part of a re-run after a timeout, about 4,000 prompt tokens each; login and plan errors cost no tokens.

    How often. how many runs print 'Model ... failed. Retrying with ...' after a timeout, a login error or a plan-limit error

  4. LP-PC-01 Put cache marks where the provider needs them

    src/feature/generate-commit-message.ts:913 · severity low · saves prefill · how often is assumed

    What happens. The agentic loop on the Anthropic API sends no cache mark, so on a large diff the second step resends the tools, the instructions and the changed-file tree (about 3,300 tokens) uncached.

    The change. Add an Anthropic cache mark on the first user message through providerOptions.anthropic.cacheControl when the provider is anthropic.

    Why it helps. Sonnet 5.5 caches prefixes from 512 tokens and the second step comes seconds after the first, so the mark pays back within one run.

    Estimate about 16k prompt tokens per 1,000 calls not served from cache (estimate)

    Assumptions. Anthropic API is 5% of calls, half of them on Sonnet (the default claude-haiku-4-5 needs 4,096 tokens, more than this prefix), and 20% of those are the second step of a large-diff run.

    How often. share of runs on the Anthropic API with a Sonnet model and a diff large enough for a second agent step

Already known to the project

The project’s own issues, pull requests or docs already cover these, so they are not counted above and are left out of the static score.

  1. LP-GE-05 Retry only retryable errors; never retry a truncation unchanged

    src/feature/generate-commit-message.ts:722 · severity high · saves prefill and generation · how often is assumed

    What happens. The one-shot path retries up to three times when the answer is empty, ends in an ellipsis or lacks a body (generate-commit-message.ts:652-737), but never reads result.finishReason. An answer cut off at the 2,048-token limit, typically a reasoning model that spent the budget thinking, is sent again with the same limit twice more. The agentic path re-runs the whole agent once when nothing was submitted (lines 985-1001).

    The change. After generateText, if result.finishReason is 'length', do not retry unchanged: retry once with a larger maxOutputTokens (or lower reasoning), or fail with a message that names the max-output-tokens setting.

    Why it helps. Each unchanged retry pays for the prompt again and usually stops at the same limit, so a cut-off run costs three full generations and still fails.

    Already reported. PR #367 (merged) saw finish_reason length on Gemini 2.5 Flash and raised the limit from 512 to 2,048 tokens; PR #368 (landed on develop, adapted) made max-output-tokens configurable. Neither reads finishReason, so a cut-off answer is still retried unchanged. https://github.com/Nutlope/aicommits/pull/367

    Estimate about 41k output and 80k prompt tokens per 1,000 calls (estimate)

    Assumptions. 1% of one-shot calls end at the output limit, each retried twice with about 4,000 prompt tokens; the retry on an empty answer after a normal stop (tested at tests/specs/generate-commit-message.ts:912) is fine and stays.

    How often. how often finishReason is 'length' on the one-shot call (Groq gpt-oss, OpenCode Go, custom reasoning models), from the provider logs or by logging result.finishReason

Declined by the project

Other problems the audit found

Problems read in the code that cost no tokens of their own, such as a cost meter or an error path. Not scored.

  1. A cut-off answer is retried unchanged, and a cut-off body is committed as complete

    src/feature/generate-commit-message.ts:725 · LP-GE-12 Read the finish reason before using an answer · severity medium · the same problem as finding 5

    What happens. runOneShot never reads result.finishReason. An answer that stopped at the 2,048-token limit is sent again with the same limit up to two more times when it is empty, and then fails with 'The model did not generate a commit message'. When it has a subject and part of a body, parseOneShotMessage accepts it, so a description cut off mid-sentence is committed as if whole.

    The change. After generateText, treat finishReason 'length' as its own case: do not parse the partial text and do not retry with the same options; retry once with a larger maxOutputTokens, or fail with a message that names the max-output-tokens setting.

    Why it matters. A reasoning model that spent the budget thinking usually stops at the same place on every unchanged retry.

    To check. A MockLanguageModelV4 returning finishReason 'length' with empty text makes one call (or two with a larger limit) instead of three; one returning a subject, a partial body and finishReason 'length' is not returned as a commit message.

  2. Claude Agent token usage leaves out cache reads and writes

    src/feature/subscriptions/claude-agent.ts:105 · LP-GE-11 Meter every billed token, cached and unfinished ones too · severity low

    What happens. The usage record copies result.usage.input_tokens only. On Anthropic that field counts only the tokens after the last cache breakpoint, so cache_read_input_tokens and cache_creation_input_tokens are dropped. Nothing displays usage today, but open PR #382 adds a token-usage line in interactive mode that reads this field.

    The change. Add cache_read_input_tokens and cache_creation_input_tokens to inputTokens (or carry them in inputTokenDetails) before usage is shown.

    To check. For one Claude Agent run, the shown input total equals input_tokens plus both cache fields in the SDK result message.

  3. The README says the timeout is per network request; it covers the whole generation

    README.md:405 · LP-GE-15 Give each timeout one meaning, and set one · severity high

    What happens. README.md says timeout is 'the timeout for network requests'. Since PR #351 it is one deadline for the whole generation (generate-commit-message.ts:146-169), shared by every chunk call and the combine call of a large diff, and the hosted providers other than Together AI keep 10 seconds for all of it.

    The change. Say in the README that the timeout covers the whole generation, and suggest a larger value for large diffs on hosted providers.

    To check. The README's timeout section matches createGenerationBudget.

The maintainers’ response

No response from the maintainers yet.

How this was made

The llm-call-audit skill read the code and wrote findings.json; nothing was run against the project’s providers. The full audit page is what leanprompt report --html writes from the same findings.

Corrections and takedown: email info@podwarden.com or open an issue.