The page leanprompt report --html writes for Abrechen2/sublarr at commit 76d1c08, audited 2026-11-28. 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 Abrechen2/sublarr

leanprompt audit of Abrechen2/sublarr

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.

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

The biggest, at backend/translation/llm_base.py:481, about 395k tokens per 1,000 calls: the five hosted backends (Claude, ChatGPT, Gemini, Mistral, DeepSeek) put every glossary term into the system prompt of every batch, up to 100 terms.

Together about 403k 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 5 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-PD-04backend/translation/llm_base.py:481395k prompt
LP-GE-05backend/translation/llm_base.py:3384k prompt, 4k 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

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

The five hosted backends (Claude, ChatGPT, Gemini, Mistral, DeepSeek) put every glossary term into the system prompt of every batch, up to 100 terms.

Finding 1. backend/translation/llm_base.py:481 medium LP-PD-04 how often is assumed

The Ollama and OpenAI-compatible path already keeps only terms that occur in the batch and at most 15.

What to change
In LLMBackend._assemble_messages, reuse the filter from build_prompt_with_glossary: keep an entry only when its source term occurs in the escaped lines being translated, and cap the count.
Why it matters
A default batch is 15 lines, about 180 tokens of subtitle text, while 100 terms are about 800 tokens that are sent again for every batch of the file. Terms that do not occur in the batch cannot change the output.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many approved glossary terms a typical series has in a real install (the cap is glossary_max_terms, default 100)
Who reaches this
series with a large glossary, on the Claude, ChatGPT, Gemini, Mistral or DeepSeek backends
Estimate
about 790 prompt tokens per call on a series with a full 100-term glossary; about 395k per 1,000 calls if half the calls run with one (estimate)
What the estimate assumes

about 8 tokens per 'source -> target' pair (estimated from character count, not tokenised); batch_size 15 and lookback 10 / lookahead 5 as in config_settings.py; 1 to 3 terms occur per batch; half of all calls carry a full glossary, which is a guess.

How to check the fix Log tokens_in for one batch before and after on a series with 100 terms: it should drop by roughly the size of the terms that do not occur in the batch.

When an answer is cut off at the output cap it comes back with too few lines, and the line-count retry sends the same batch again with the same cap, because the cap is computed from the source lines only.

Finding 2. backend/translation/llm_base.py:338 high LP-GE-05 how often is assumed

The retry that fails the same way is followed by a batch split.

What to change
Read the stop reason in _attempt. On a length stop, retry with a larger max_tokens (or go straight to splitting the batch) instead of resending with the same cap.
Why it matters
A repeated cut-off pays for the whole prompt and the whole generated answer a second time and still ends short.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how often finish_reason is length / max_tokens / MAX_TOKENS on translation calls, from the translation_events or provider logs
Who reaches this
only batches whose answer reaches the output cap
Estimate
about 4k prompt and 4k output tokens per 1,000 calls if 1 percent of calls are cut off (estimate; the real rate is not known)
What the estimate assumes

1 percent of calls reach the cap; about 400 prompt and 400 output tokens per affected attempt; average call 800 prompt and 250 output tokens.

How to check the fix Force a small cap on one batch: before, two calls end at the same cap and the batch is split; after, the second call carries a larger cap or the split happens at once.

The cache mark covers the whole system block, and that block changes with every batch (line count, previous and following lines, glossary, strict flag), so it cannot be read back.

Finding 3. backend/translation/claude.py:94 low LP-PC-01 size is assumed

Below the provider's minimum it does nothing; above it every batch pays the cache-write price and never gets a read.

What to change
Keep the mark only on a block that is identical across the batches of a file, and put the per-batch parts after it, or remove the mark.
Why it matters
A cache write is billed above the normal input price and a block that differs on every call is never read.
How big it is
The code shows the problem and how often it happens; how many tokens it costs each time is assumed. To measure it: the system block size on a real install with a large glossary or series context (the mark only matters above 1,024 tokens for claude-sonnet-4-6)
Who reaches this
Claude users whose system block exceeds 1,024 tokens
Estimate
no tokens lost today on a typical block of a few hundred tokens (estimate); about 25 percent extra on the system tokens once the block exceeds the minimum
What the estimate assumes

typical system block of a few hundred tokens with 15 lines, 10 previous and 5 following lines; the 1,024-token minimum for claude-sonnet-4-6 is from the captured Anthropic page.

How to check the fix Send two consecutive batches of one file and compare cache_creation_input_tokens and cache_read_input_tokens: before, reads stay 0.

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.

A cut-off answer is stored as a complete translation

Note 1. backend/translation/llm_base.py:307 LP-GE-12 high not scored

_attempt reads the finish reason only to catch content_filter. Claude's max_tokens, OpenAI-style length, Gemini's MAX_TOKENS and Ollama's done_reason are mapped into LLMResponse.finish_reason and then never read. If the cap is hit inside the last line, the line count is still right and the batch passes _verify_batch, so the cut-off last line is written to the translation memory and the subtitle file.

What to change
Treat a length stop as a failed attempt in _attempt (raise a TranslationContentError subclass), so the batch is split or retried with a larger cap and nothing partial reaches the cache.
Same problem as
finding 2

How to check the fix Force a tiny max_tokens on a 3-line batch: before, 3 lines come back and the last one is cut; after, the attempt is rejected and nothing is cached.

The Gemini default and a shipped Claude preset name models that are scheduled or retired

Note 2. backend/translation/gemini.py:24 LP-GE-13 medium not scored

GeminiBackend defaults to gemini-2.5-pro (also gemini.py:40 and the price sheet), which our retirements table lists as scheduled to shut down on 2026-12-01 (table checked 2026-11-27; the Gemini deprecations page itself would not render for our fetcher, so this needs confirming there). The claude_haiku preset in routes/translate/_helpers.py:44 uses claude-3-haiku-20240307, which Anthropic's deprecations page lists as retired.

What to change
Change the Gemini default and price-sheet entries to a model Google still serves, and replace the claude_haiku preset id with a current Haiku id.

How to check the fix Send the health check from the settings page after the change; with the old ids the provider answers with a model-not-found error once the shutdown date has passed.

Cost is recorded as zero for every model that is not in the price sheet, including the shipped presets

Note 3. backend/translation/price_sheet.py:70 LP-GE-11 medium not scored

get_llm_price returns (0, 0) for an unknown backend and model pair. The presets in routes/translate/_helpers.py use openai_compat with deepseek-chat, gemini-1.5-flash, claude-3-haiku and mistral-medium-latest, and the sheet has openai_compat entries only for gpt-4o and gpt-4o-mini, so their events record cost_micro_usd 0.

What to change
Add the preset models to the sheet, or show the cost as unknown rather than 0.

How to check the fix Translate a batch with the deepseek_v3 preset and compare cost_micro_usd with tokens times the provider price.

Per-line quality scoring cannot run on hosted backends and reports 50

Note 4. backend/translation/__init__.py:327 not scored

evaluate_line_quality asks only ollama and openai_compat, and _call_backend_raw calls backend._call_openai, which OpenAICompatBackend does not define. For an openai_compat chain the raw call returns None and the line gets DEFAULT_QUALITY_SCORE (50). With translation_quality_threshold above 50 every line would then be re-translated twice.

What to change
Implement _call_openai (or route through _call_api) or hide the setting for chains without Ollama.

How to check the fix Run the scoring pass on an openai_compat-only chain and check that scores differ from 50.

The openai_compat max_retries setting is never read

Note 5. backend/translation/openai_compat.py:152 LP-GE-17 low not scored

The settings page offers 'Number of retry attempts on failure' and the client is built with max_retries=0 'We handle retries ourselves', but _max_retries has no caller, so no retry happens on a transient API error; the batch goes straight to the next backend.

What to change
Use the setting with backoff for 429 and 5xx, or remove the field.

How to check the fix Return a 503 once from a stub server and check that a second request is sent.

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-PD-04 at backend/translation/llm_base.py:481: The five hosted backends (Claude, ChatGPT, Gemini, Mistral, DeepSeek) put every glossary term into the system prompt of every batch, up to 100 terms. The Ollama and OpenAI-compatible path already keeps only terms that occur in the batch and at most 15.
2. LP-GE-05 at backend/translation/llm_base.py:338: When an answer is cut off at the output cap it comes back with too few lines, and the line-count retry sends the same batch again with the same cap, because the cap is computed from the source lines only. The retry that fails the same way is followed by a batch split.
3. LP-PC-01 at backend/translation/claude.py:94: The cache mark covers the whole system block, and that block changes with every batch (line count, previous and following lines, glossary, strict flag), so it cannot be read back. Below the provider's minimum it does nothing; above it every batch pays the cache-write price and never gets a read.

Other problems found (check each against the code first; not scored):
- A cut-off answer is stored as a complete translation (backend/translation/llm_base.py:307) [LP-GE-12]: _attempt reads the finish reason only to catch content_filter. Claude's max_tokens, OpenAI-style length, Gemini's MAX_TOKENS and Ollama's done_reason are mapped into LLMResponse.finish_reason and then never read. If the cap is hit inside the last line, the line count is still right and the batch passes _verify_batch, so the cut-off last line is written to the translation memory and the subtitle file. Change: Treat a length stop as a failed attempt in _attempt (raise a TranslationContentError subclass), so the batch is split or retried with a larger cap and nothing partial reaches the cache.
- The Gemini default and a shipped Claude preset name models that are scheduled or retired (backend/translation/gemini.py:24) [LP-GE-13]: GeminiBackend defaults to gemini-2.5-pro (also gemini.py:40 and the price sheet), which our retirements table lists as scheduled to shut down on 2026-12-01 (table checked 2026-11-27; the Gemini deprecations page itself would not render for our fetcher, so this needs confirming there). The claude_haiku preset in routes/translate/_helpers.py:44 uses claude-3-haiku-20240307, which Anthropic's deprecations page lists as retired. Change: Change the Gemini default and price-sheet entries to a model Google still serves, and replace the claude_haiku preset id with a current Haiku id.
- Cost is recorded as zero for every model that is not in the price sheet, including the shipped presets (backend/translation/price_sheet.py:70) [LP-GE-11]: get_llm_price returns (0, 0) for an unknown backend and model pair. The presets in routes/translate/_helpers.py use openai_compat with deepseek-chat, gemini-1.5-flash, claude-3-haiku and mistral-medium-latest, and the sheet has openai_compat entries only for gpt-4o and gpt-4o-mini, so their events record cost_micro_usd 0. Change: Add the preset models to the sheet, or show the cost as unknown rather than 0.
- Per-line quality scoring cannot run on hosted backends and reports 50 (backend/translation/__init__.py:327): evaluate_line_quality asks only ollama and openai_compat, and _call_backend_raw calls backend._call_openai, which OpenAICompatBackend does not define. For an openai_compat chain the raw call returns None and the line gets DEFAULT_QUALITY_SCORE (50). With translation_quality_threshold above 50 every line would then be re-translated twice. Change: Implement _call_openai (or route through _call_api) or hide the setting for chains without Ollama.
- The openai_compat max_retries setting is never read (backend/translation/openai_compat.py:152) [LP-GE-17]: The settings page offers 'Number of retry attempts on failure' and the client is built with max_retries=0 'We handle retries ourselves', but _max_retries has no caller, so no retry happens on a transient API error; the batch goes straight to the next backend. Change: Use the setting with backoff for 429 and 5xx, or remove the field.

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

75static
E, prefill reuse
0.60
S, prefix stability
1.00
G, generation waste
0.02
Default shares
0 of 3

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-28 (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.