The page leanprompt report --html writes for abi/screenshot-to-code at commit f2e5bbd, 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 abi/screenshot-to-code

leanprompt audit of abi/screenshot-to-code

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.

1 place where this app pays for tokens it doesn't need

The biggest, at backend/agent/tools/runtime.py:57, about 900k tokens per 1,000 calls: when a turn is cut off at the 50,000-token output limit, nothing reads why it stopped.

Together about 900k 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 2 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-GE-05backend/agent/tools/runtime.py:57675k prompt, 225k 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

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

When a turn is cut off at the 50,000-token output limit, nothing reads why it stopped.

Finding 1. backend/agent/tools/runtime.py:57 high LP-GE-05 how often is assumed

On OpenAI the cut-off tool call arrives as broken JSON and the whole broken text is sent back to the model as the tool result. The model is told to try again with the same limit, so it writes the whole file again.

What to change
Read the stop reason on each provider (OpenAI status incomplete, Anthropic stop_reason max_tokens, Gemini finishReason MAX_TOKENS). On a cut-off, do not echo the broken arguments back: end the variant with a clear 'output limit reached' error, or continue from the saved file with a higher limit.
Why it matters
Each cut-off turn bills up to 50,000 output tokens, the retry bills them again, and the echoed broken arguments stay in the history and are re-read on every later turn.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how often a turn ends at the 50,000-token output limit (OpenAI status incomplete, Anthropic stop_reason max_tokens, Gemini MAX_TOKENS), from the run records the app already writes
Who reaches this
OpenAI models; Anthropic and Gemini see the cut-off as a silent partial file instead
Estimate
about 225k output and 675k prompt tokens per 1,000 calls
What the estimate assumes

half a percent of turns end at the limit (guess; only high-effort reasoning models or very large pages should); each wasted turn is about 45k output tokens; the echoed text is carried by about 3 later turns; average turn is 30k prompt and 5k output tokens. Applies mostly to OpenAI, where arguments arrive as broken JSON; on Anthropic the cut-off call is accepted as complete (see the notes).

How to check the fix Force a low max_output_tokens in a test double that returns status incomplete with half a create_file argument; the run should stop with a clear error and the next request should not contain the broken arguments.

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 page is saved and shown as finished

Note 1. backend/agent/providers/anthropic/provider.py:403 LP-GE-12 high not scored

All three providers cap output at 50,000 tokens (anthropic/provider.py:371, openai.py:531, gemini.py:325) and none reads the stop reason. On Anthropic the SDK (0.84.0, lib/streaming/_messages.py:480) parses partial tool JSON, so a create_file cut off mid-page arrives as a valid but shorter 'content'. runtime.py:103-113 saves it, replies 'Successfully created file', and the page is shown as complete. On Gemini and a no-tool OpenAI turn the same cut-off text is returned as the final answer.

What to change
Read final_message.stop_reason (Anthropic), response status and incomplete_details (OpenAI) and finishReason (Gemini) after each turn. On max_tokens, do not run the tool call as success; end the variant with an error or ask the model to continue.
Why it matters
The user sees a half page marked as done and nothing says it was cut.

How to check the fix Mock a final message with stop_reason max_tokens and a half create_file input; the variant should end with an error, not a saved file.

Cut-off OpenAI turns are not counted against the $3 limit

Note 2. backend/agent/providers/openai.py:246 LP-GE-11 medium not scored

Usage is read only from the response.completed event. A turn that ends at max_output_tokens finishes with response.incomplete, so state.turn_usage stays None (openai.py:548) and the most expensive turn is never added to the total that engine.py:270-276 checks against GENERATION_MAX_COST_USD. Separately, pricing.py:19-20 says cache writes for gpt-5.6 and 6.x are billed at 1.25x but left at 0.

What to change
Read usage on response.incomplete (and response.failed when usage is present) as well as response.completed. Add the cache-write rate once the Responses usage exposes it.
Why it matters
The spend ceiling undercounts exactly the turns that cost the most, so a run can pass $3.

How to check the fix Feed parse_event a response.incomplete event with usage; session.total_cost_usd() should include it.

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-GE-05 at backend/agent/tools/runtime.py:57: When a turn is cut off at the 50,000-token output limit, nothing reads why it stopped. On OpenAI the cut-off tool call arrives as broken JSON and the whole broken text is sent back to the model as the tool result. The model is told to try again with the same limit, so it writes the whole file again.

Other problems found (check each against the code first; not scored):
- A cut-off page is saved and shown as finished (backend/agent/providers/anthropic/provider.py:403) [LP-GE-12]: All three providers cap output at 50,000 tokens (anthropic/provider.py:371, openai.py:531, gemini.py:325) and none reads the stop reason. On Anthropic the SDK (0.84.0, lib/streaming/_messages.py:480) parses partial tool JSON, so a create_file cut off mid-page arrives as a valid but shorter 'content'. runtime.py:103-113 saves it, replies 'Successfully created file', and the page is shown as complete. On Gemini and a no-tool OpenAI turn the same cut-off text is returned as the final answer. Change: Read final_message.stop_reason (Anthropic), response status and incomplete_details (OpenAI) and finishReason (Gemini) after each turn. On max_tokens, do not run the tool call as success; end the variant with an error or ask the model to continue.
- Cut-off OpenAI turns are not counted against the $3 limit (backend/agent/providers/openai.py:246) [LP-GE-11]: Usage is read only from the response.completed event. A turn that ends at max_output_tokens finishes with response.incomplete, so state.turn_usage stays None (openai.py:548) and the most expensive turn is never added to the total that engine.py:270-276 checks against GENERATION_MAX_COST_USD. Separately, pricing.py:19-20 says cache writes for gpt-5.6 and 6.x are billed at 1.25x but left at 0. Change: Read usage on response.incomplete (and response.failed when usage is present) as well as response.completed. Add the cache-write rate once the Responses usage exposes it.

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

96static
E, prefill reuse
0.98
S, prefix stability
1.00
G, generation waste
0.05
Default shares
0 of 1

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.