The page leanprompt report --html writes for ChatGPTBox-dev/chatGPTBox at commit be0d714, audited 2026-11-27. Every figure on this page is an estimate from reading the code, not a measurement of the app in use. Corrections and takedown: email info@podwarden.com or open an issue. Back to the audit of ChatGPTBox-dev/chatGPTBox

leanprompt audit of ChatGPTBox-dev/chatGPTBox

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.

3 places where this app pays for tokens it doesn't need

The biggest, at src/services/apis/claude-api.mjs:31, about 450k tokens per 1,000 calls: the Claude API request body has no cache_control anywhere, so Anthropic caches nothing.

Together about 790k tokens per 1,000 calls An estimate from the code, not a measurement.

Tokens per 1,000 calls, by finding, and each one's share of the total

Plus 1 finding that costs no tokens today, listed with the findings and not counted as places.

Plus 4 other problems the audit found, listed after the findings. Not scored.

What this costs you

Every figure here is an estimate from the code, not a measurement. Findings can overlap (one failed call can show up in two), so the sum may count some tokens twice. Money is not part of the score. The table lists this app's findings first, largest first, then its open questions, then the questions for the server's administrator, then the findings the project already knows about, which are not in the totals.

FindingWhereTokens per 1,000 calls
LP-PC-01src/services/apis/claude-api.mjs:31450k not cached; the fix writes 450k to the cache at the write price
LP-PC-06src/services/apis/openai-compatible-core.mjs:95240k not cached
LP-GE-03src/services/apis/openai-compatible-core.mjs:99100k output

To see this in money, add to leanprompt.yaml:

  • volume: {calls_per_month: N}: how many calls the app makes a month (with targets:, on each entry)
  • prices: per model: input, cached_input and output per 1M tokens (US dollars, or set currency), with source and checked date (or, self-hosted, engine: {prefill_tokens_per_second: N})

leanprompt never guesses a volume or a price. Your coding agent can look up the provider's current price page and add it with the date; how.

What's wrong and what to change

4 open, 0 fixed. Largest first, by the audit's estimate of tokens lost per 1,000 calls.

The Claude API request body has no cache_control anywhere, so Anthropic caches nothing.

Finding 1. src/services/apis/claude-api.mjs:31 high LP-PC-01

Every follow-up question about a summarised page or video resends the whole earlier conversation, including the page text, at the full input price.

What to change
Add top-level automatic caching to the body: cache_control: { type: 'ephemeral' }. Anthropic then places the breakpoint on the last cacheable block and moves it forward each turn.
Why it matters
A Summarize Page or video prompt is up to about 5,900 tokens after cropText; with marks, each follow-up within 5 minutes reads it at 0.1x (0.05x on Opus 5.5 and Sonnet 5.5) instead of 1x.
Estimate
about 450k prompt tokens per 1,000 calls not served from cache (estimate)
What the estimate assumes

15% of calls go to the Claude API, half of them are follow-ups within 5 minutes carrying about 6,000 tokens of earlier conversation; default-enabled Claude models (Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5) have a 512-token minimum; the first call of each conversation pays the 1.25x write on about 6,000 tokens. Searched issues and PRs for cache_control and prompt caching: nothing.

How to check the fix Ask a follow-up within a minute of a page summary on Claude Sonnet 5.5: usage.cache_read_input_tokens goes from 0 to about the size of the first turn.

History is cut to the last maxConversationContextLength question/answer pairs (9 by default) on every request (also claude-api.mjs:26 and azure-openai-api.mjs:21).

Finding 2. src/services/apis/openai-compatible-core.mjs:95 high LP-PC-06

From the tenth turn on, each request starts with a different pair, so the provider's cache cannot reuse any of the history, and the first turn, which holds the page or video text of a summary, is dropped from the conversation.

What to change
Drop old turns in larger steps (for example keep the first pair and cut back to 5 pairs when 9 is reached), so the prefix stays the same for several turns, and keep the first pair of a summary conversation.
Why it matters
Each turn past the window recomputes the whole history at full price.
Estimate
about 240k prompt tokens per 1,000 calls not served from cache (estimate)
What the estimate assumes

3% of calls are turn 10 or later of a conversation with about 8,000 tokens of history; automatic caching on OpenAI and Gemini, marks on Claude (finding claude-marks).

How to check the fix On turn 11 of a conversation, prompt_tokens_details.cached_tokens is near 0 before the change and near the history size after it.

Every OpenAI-compatible request is capped at Max Response Token Length, 2,000 by default (src/config/index.mjs:861), and the default-enabled OpenAI modes are reasoning models whose default effort is medium.

Finding 3. src/services/apis/openai-compatible-core.mjs:99 medium LP-GE-03 how often is assumed

On Chat Completions the cap covers the hidden reasoning as well as the visible answer, so a page summary can stop part-way or before any visible text, and the app then shows it as a finished answer (see the note on line 148).

What to change
Treat finish_reason "length" as a cut-off (the note below), and raise the default limit for reasoning models, for example 16,000 for GPT-5.x/GPT-6.x and Gemini 3.x, or send a lower reasoning_effort for short tasks.
Why it matters
A cut-off answer is paid for in full (reasoning and visible tokens), and the user asks again with the same 2,000-token limit, which tends to stop at the same place.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many OpenAI-compatible answers end with finish_reason "length" on the default-enabled GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, GPT-6 Astra and Gemini 3.x modes, from the provider's request logs
Estimate
about 100k output tokens per 1,000 calls (estimate, frequency unknown)
What the estimate assumes

5% of all calls are OpenAI-compatible reasoning-model calls that hit the 2,000-token limit and are asked again; each loses the full 2,000 output tokens; 700 output tokens per average call. OpenAI's reasoning guide recommends reserving at least 25,000 tokens for reasoning and output when starting out (read 2026-11-27); GPT-6.1 Terra and GPT-6.1 Sol default to medium effort. Related, not the same: open issue #1133 / PR #1134 are about the parameter's name, not its size.

How to check the fix On GPT-6.1 Sol with defaults, summarise a long article: the provider log shows completion_tokens 2000 and finish_reason length before the change; after it, finish_reason stop.

No request has a timeout: fetchSSE passes only the Stop button's AbortController, so a provider that accepts the connection and never sends a byte leaves the answer spinning until the user presses Stop.

Finding 4. src/utils/fetch-sse.mjs:71 medium LP-GE-04

What to change
Add a first-byte timeout (for example 60 seconds, longer for reasoning models) with AbortSignal.any([controller.signal, AbortSignal.timeout(ms)]), cleared when the first chunk arrives, and report it as a timeout rather than a stop.
Why it matters
Costs no tokens by itself; it turns a silent hang into an error the user can act on.
Estimate
no tokens (reliability)
What the estimate assumes

streaming requests; the user can always press Stop.

How to check the fix Point a custom provider at a server that accepts and never answers: the card shows a timeout error after the limit.

Other problems the audit found

Problems the audit checked in the code that cost no tokens of their own, such as a spend meter that ignores cache tokens or a cut-off answer accepted as complete. They are not scored. Check each one before you change anything.

OpenAI-compatible answers cut off at the token limit are shown and saved as complete

Note 1. src/services/apis/openai-compatible-core.mjs:148 LP-GE-12 high not scored

hasFinished (lines 31-33) is true for any finish_reason, and line 148 then calls finish(), which saves the answer to history and marks it done, whether the reason was stop or length. An answer cut off at Max Response Token Length, or an empty one when a reasoning model spent the whole budget thinking, looks like a normal reply. The Claude path already handles this (claude-api.mjs:78-82 raises 'Claude reached the response token limit'). Azure has the same gap (azure-openai-api.mjs:66). This path serves OpenAI, OpenRouter, Gemini, xAI, DeepSeek, Ollama and every other OpenAI-compatible provider.

What to change
Read the reason: when finish_reason is 'length', do not save the record as complete; post the partial text and throw an error like the Claude one ('The answer reached Max Response Token Length (N). Increase it in Advanced settings and try again.'). Treat 'content_filter' the same way with its own message.
Same problem as
finding 3

How to check the fix In tests/unit/services/apis/openai-api-compat.test.mjs, a mock stream ending with finish_reason 'length' should produce an error message and no done record; the existing 'stop' tests stay green.

The Ollama keep-alive request after every answer probably evicts the conversation's cached prefix

Note 2. src/services/apis/openai-api.mjs:209 not scored

After each answer, touchOllamaKeepAlive (lines 193-224, called at 336-346) sends a second generation to /api/generate with prompt 't' and num_predict 1. Ollama defaults to one parallel slot (OLLAMA_NUM_PARALLEL, FAQ read 2026-11-27), and its prompt cache keeps only the prefix shared with the newest request, so the next turn of the conversation has to prefill the whole history again. With the default ollamaKeepAliveTime '5m' (src/config/index.mjs:852), which equals Ollama's own default residency, the request also changes nothing.

What to change
Send the documented preload request instead: { model, keep_alive } with no prompt and no options (Ollama FAQ, 'preload a model by sending the Ollama server an empty request'), and skip it entirely when the setting is the default '5m'.

How to check the fix On a local Ollama with default settings, ask two follow-ups: before the change usage.prompt_tokens on the second follow-up is about the whole history; after it, about the new message only (Ollama reports only evaluated tokens).

Pages and transcripts are cut to about 5,900 tokens for every current model, and less when the output limit is raised

Note 3. src/utils/crop-text.mjs:48 not scored

cropText reads the context size from a 'NNk' in the model's label (lines 41-45). Only GPT-4o 128k and the Kimi API and web modes have one, so every default-enabled model, including 1M-context GPT-6.1 and Gemini 3.x, gets the 8,000-token default minus 100 minus the output limit: about 5,900 tokens. The rest of a page or transcript is decimated, keeping roughly every Nth clause. Raising Max Response Token Length, which is what a cut-off answer needs, makes it worse: at 6,000 or more only 1,900 tokens of the page are sent (line 48). The count uses the GPT-2/3 tokenizer.

What to change
Give each model (or provider) a context-window value and use it instead of parsing the label, keep the output limit out of the input budget for 100k+ models, and when cropping is still needed, cut the middle once with a marker (as #809 proposed) instead of decimating.
Already reported
open since 2024-10: cropping by decimation produces garbled text; PR #809 (crop the middle) closed unmerged 2025-08; #679 asked for full transcripts and was told to pick a longer-context mode https://github.com/ChatGPTBox-dev/chatGPTBox/issues/800

How to check the fix Summarise a 2-hour YouTube video on GPT-6.1 Sol: the console's 'input maxLength' log line shows 5900 before the change and the model's window after it.

The model list still offers OpenAI models that have been shut down

Note 4. src/config/index.mjs:328 LP-GE-13 low not scored

OpenAI's deprecations page (read 2026-11-27) lists gpt-5-chat-latest and gpt-5.1-chat-latest as shut down on 2026-07-23, gpt-5.2-chat-latest and gpt-5.3-chat-latest on 2026-08-10, gpt-3.5-turbo-instruct on 2026-09-28 and gpt-4.1-nano on 2026-10-23; gpt-5 and o3 shut down on 2026-12-11, gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini on 2027-01-14. The modes remain selectable (lines 325-351, 439) and saved selections are preserved, so a user who picked one gets a provider error.

What to change
Remove the shut-down ids or migrate saved selections to OpenAI's named replacements (gpt-5.6-sol for the chat-latest ids, gpt-6-luna for gpt-4o/4.1, gpt-6.1-sol for gpt-5 and o3).

How to check the fix After the migration, a profile with chatgptApi5_2Latest saved opens with the replacement selected.

Fix it with your coding agent

Paste this into Claude Code, Codex, Cursor or any coding assistant. It will check each finding against your code and propose fixes one at a time, asking before it changes anything.

Please check and fix the LLM-call findings from a leanprompt audit of this repository.

1. If the leanprompt skills are not installed for you here, install them: npx leanprompt@0.1.0-dev.15 install
2. Read .leanprompt/findings.json and leanprompt-report.md. If they are missing, use the list below.
3. Check each finding against the code before you change anything. The audit can be wrong: if a finding does not hold, tell me why and leave that code alone.
4. Fix one finding at a time. Show me the change as a small diff and apply it only after I say yes.
5. Prove each fix with the measure-loop skill: a before and after on the same scenario. Ask me before running anything that sends real, billed requests.
6. When a fix is proved, set "fixed": true on its finding in .leanprompt/findings.json and run npx leanprompt@0.1.0-dev.15 score.

Findings, largest first:
1. LP-PC-01 at src/services/apis/claude-api.mjs:31: The Claude API request body has no cache_control anywhere, so Anthropic caches nothing. Every follow-up question about a summarised page or video resends the whole earlier conversation, including the page text, at the full input price.
2. LP-PC-06 at src/services/apis/openai-compatible-core.mjs:95: History is cut to the last maxConversationContextLength question/answer pairs (9 by default) on every request (also claude-api.mjs:26 and azure-openai-api.mjs:21). From the tenth turn on, each request starts with a different pair, so the provider's cache cannot reuse any of the history, and the first turn, which holds the page or video text of a summary, is dropped from the conversation.
3. LP-GE-03 at src/services/apis/openai-compatible-core.mjs:99: Every OpenAI-compatible request is capped at Max Response Token Length, 2,000 by default (src/config/index.mjs:861), and the default-enabled OpenAI modes are reasoning models whose default effort is medium. On Chat Completions the cap covers the hidden reasoning as well as the visible answer, so a page summary can stop part-way or before any visible text, and the app then shows it as a finished answer (see the note on line 148).
4. LP-GE-04 at src/utils/fetch-sse.mjs:71: No request has a timeout: fetchSSE passes only the Stop button's AbortController, so a provider that accepts the connection and never sends a byte leaves the answer spinning until the user presses Stop.

Other problems found (check each against the code first; not scored):
- OpenAI-compatible answers cut off at the token limit are shown and saved as complete (src/services/apis/openai-compatible-core.mjs:148) [LP-GE-12]: hasFinished (lines 31-33) is true for any finish_reason, and line 148 then calls finish(), which saves the answer to history and marks it done, whether the reason was stop or length. An answer cut off at Max Response Token Length, or an empty one when a reasoning model spent the whole budget thinking, looks like a normal reply. The Claude path already handles this (claude-api.mjs:78-82 raises 'Claude reached the response token limit'). Azure has the same gap (azure-openai-api.mjs:66). This path serves OpenAI, OpenRouter, Gemini, xAI, DeepSeek, Ollama and every other OpenAI-compatible provider. Change: Read the reason: when finish_reason is 'length', do not save the record as complete; post the partial text and throw an error like the Claude one ('The answer reached Max Response Token Length (N). Increase it in Advanced settings and try again.'). Treat 'content_filter' the same way with its own message.
- The Ollama keep-alive request after every answer probably evicts the conversation's cached prefix (src/services/apis/openai-api.mjs:209): After each answer, touchOllamaKeepAlive (lines 193-224, called at 336-346) sends a second generation to /api/generate with prompt 't' and num_predict 1. Ollama defaults to one parallel slot (OLLAMA_NUM_PARALLEL, FAQ read 2026-11-27), and its prompt cache keeps only the prefix shared with the newest request, so the next turn of the conversation has to prefill the whole history again. With the default ollamaKeepAliveTime '5m' (src/config/index.mjs:852), which equals Ollama's own default residency, the request also changes nothing. Change: Send the documented preload request instead: { model, keep_alive } with no prompt and no options (Ollama FAQ, 'preload a model by sending the Ollama server an empty request'), and skip it entirely when the setting is the default '5m'.
- Pages and transcripts are cut to about 5,900 tokens for every current model, and less when the output limit is raised (src/utils/crop-text.mjs:48): cropText reads the context size from a 'NNk' in the model's label (lines 41-45). Only GPT-4o 128k and the Kimi API and web modes have one, so every default-enabled model, including 1M-context GPT-6.1 and Gemini 3.x, gets the 8,000-token default minus 100 minus the output limit: about 5,900 tokens. The rest of a page or transcript is decimated, keeping roughly every Nth clause. Raising Max Response Token Length, which is what a cut-off answer needs, makes it worse: at 6,000 or more only 1,900 tokens of the page are sent (line 48). The count uses the GPT-2/3 tokenizer. Change: Give each model (or provider) a context-window value and use it instead of parsing the label, keep the output limit out of the input budget for 100k+ models, and when cropping is still needed, cut the middle once with a marker (as #809 proposed) instead of decimating.
- The model list still offers OpenAI models that have been shut down (src/config/index.mjs:328) [LP-GE-13]: OpenAI's deprecations page (read 2026-11-27) lists gpt-5-chat-latest and gpt-5.1-chat-latest as shut down on 2026-07-23, gpt-5.2-chat-latest and gpt-5.3-chat-latest on 2026-08-10, gpt-3.5-turbo-instruct on 2026-09-28 and gpt-4.1-nano on 2026-10-23; gpt-5 and o3 shut down on 2026-12-11, gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini on 2027-01-14. The modes remain selectable (lines 325-351, 439) and saved selections are preserved, so a user who picked one gets a provider error. Change: Remove the shut-down ids or migrate saved selections to OpenAI's named replacements (gpt-5.6-sol for the chat-latest ids, gpt-6-luna for gpt-4o/4.1, gpt-6.1-sol for gpt-5 and o3).

Score

One number from 0 to 100 for how well this app avoids paying for the same tokens twice; higher is better. It is computed from the findings above (static) or from your usage log (measured).

84static
E, prefill reuse
0.84
S, prefix stability
1.00
G, generation waste
0.14
Default shares
0 of 4

Findings scored with severity defaults, not estimates. The fewer, the more the static score says about this app.

A static score is an estimate from the audit's findings, not a measurement.

Scored 2026-11-27 (the date on the machine that ran it).

Questions for the owner

These were not answered during the audit. Until they are, the page shows tokens only and ranks the advice without a priority.

  • Priority: which matters most for this app, cost, speed or quality (or weights)? Not set, so the advice uses equal weights. Answer with priority: in leanprompt.yaml.
  • Volume: how many calls does the app make a month? Answer with volume: {calls_per_month: N, source: "..."} in leanprompt.yaml.
  • Prices: what does each model cost (input, cached input, output per 1M tokens, with the source and the date it was read, and the currency if not US dollars)? Answer with prices: in leanprompt.yaml.