The page leanprompt report --html writes for every-app/open-seo at commit 6f68494, 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 every-app/open-seo

leanprompt audit of every-app/open-seo

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 src/server/features/projects/services/websiteResearch.ts:58, about 15k tokens per run: when website research ends with output that does not parse, retryInvalidOutput runs the whole request again, up to two more times, as a fresh tool-using conversation with the same 6000-token output limit.

Together about 15k tokens per run (one website research run, 1 to 3 attempts of up to 7 model steps) An estimate from the code, not a measurement.

Tokens per run (one website research run, 1 to 3 attempts of up to 7 model steps), 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.

A run is one website research run, 1 to 3 attempts of up to 7 model steps. Per-run figures are a separate total, never added to the figures per 1,000 calls.

FindingWhereTokens per run
LP-GE-05src/server/features/projects/services/websiteResearch.ts:589k prompt, 6k output

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

  • 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, then per run.

When website research ends with output that does not parse, retryInvalidOutput runs the whole request again, up to two more times, as a fresh tool-using conversation with the same 6000-token output limit.

Finding 1. src/server/features/projects/services/websiteResearch.ts:58 medium LP-GE-05 how often is assumed

It never looks at the error's finishReason, so an answer cut off at the limit (reasoning tokens count toward it) is retried the same way and is likely to be cut off again.

What to change
In the catch, read error.finishReason. On 'length', raise maxOutputTokens for the next attempt (or lower the effort or the amount asked for) instead of resending the same request; keep the retry as it is for a normal stop with bad JSON.
Why it matters
Each attempt re-runs up to seven model steps and the paid searches and page reads they trigger, and bills the full output again. A reply that hit the limit repeats the same cost and the same failure.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: How often generateText throws NoObjectGeneratedError with finishReason 'length' in website research, from the Workers logs or the seo spend rows.
Estimate
up to about 6,000 output tokens plus a full tool loop per wasted attempt, at most two attempts per run (estimate)
What the estimate assumes

Only runs whose first attempt ends in a length cut-off are affected; how many that is is not known from the code. Prompt figure assumes about seven steps of a few thousand input tokens, mostly cached.

How to check the fix Force a small maxOutputTokens in a test, make the model reply long, and check that the second attempt is sent with a larger limit and that the number of search calls does not double.

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.

SAM meters a missing OpenRouter cost as zero, where the other paths fail closed

Note 1. src/server/features/sam/SamChatAgent.ts:426 LP-GE-11 low not scored

SamChatAgent.ts:426 and :257 read the step cost through openRouterCostUsd, which returns 0 when providerMetadata has no openrouter.usage.cost (chatAgent.ts:34-37). The other hosted paths use requireOpenRouterCostUsd (chatAgent.ts:44-51), whose comment says hosted should fail closed when the cost is missing. A hosted SAM step whose reply lacks the cost field is therefore billed nothing and the turn goes on.

What to change
Use requireOpenRouterCostUsd in SAM's onStepFinish and compaction path, or log a warning when the cost is absent on hosted, so a provider route that drops usage accounting is seen.

How to check the fix In a test, pass providerMetadata {} on a hosted turn and check that the turn errors or logs, instead of recording 0.

The compaction summary call has no output limit, no deadline and no finish check

Note 2. src/server/features/sam/SamChatAgent.ts:253 LP-GE-15 medium not scored

summarizeForCompaction calls generateText with only a model and a prompt, over a transcript that has passed an estimated 120,000 tokens (SamChatAgent.ts:84). It sets no maxOutputTokens and no abortSignal, so a stalled provider holds the turn until the platform stops it, and result.text is stored as the summary without reading finishReason; a summary cut off by a provider default limit replaces the history it summarises.

What to change
Add a maxOutputTokens sized for the summary and an AbortSignal.timeout like the other generateText calls in the repo (60 to 120 seconds), and throw or keep the old history when finishReason is 'length'.

How to check the fix Stub the model to return finishReason 'length' and check that compaction does not store the partial text.

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 src/server/features/projects/services/websiteResearch.ts:58: When website research ends with output that does not parse, retryInvalidOutput runs the whole request again, up to two more times, as a fresh tool-using conversation with the same 6000-token output limit. It never looks at the error's finishReason, so an answer cut off at the limit (reasoning tokens count toward it) is retried the same way and is likely to be cut off again.

Other problems found (check each against the code first; not scored):
- SAM meters a missing OpenRouter cost as zero, where the other paths fail closed (src/server/features/sam/SamChatAgent.ts:426) [LP-GE-11]: SamChatAgent.ts:426 and :257 read the step cost through openRouterCostUsd, which returns 0 when providerMetadata has no openrouter.usage.cost (chatAgent.ts:34-37). The other hosted paths use requireOpenRouterCostUsd (chatAgent.ts:44-51), whose comment says hosted should fail closed when the cost is missing. A hosted SAM step whose reply lacks the cost field is therefore billed nothing and the turn goes on. Change: Use requireOpenRouterCostUsd in SAM's onStepFinish and compaction path, or log a warning when the cost is absent on hosted, so a provider route that drops usage accounting is seen.
- The compaction summary call has no output limit, no deadline and no finish check (src/server/features/sam/SamChatAgent.ts:253) [LP-GE-15]: summarizeForCompaction calls generateText with only a model and a prompt, over a transcript that has passed an estimated 120,000 tokens (SamChatAgent.ts:84). It sets no maxOutputTokens and no abortSignal, so a stalled provider holds the turn until the platform stops it, and result.text is stored as the summary without reading finishReason; a summary cut off by a provider default limit replaces the history it summarises. Change: Add a maxOutputTokens sized for the summary and an AbortSignal.timeout like the other generateText calls in the repo (60 to 120 seconds), and throw or keep the old history when finishReason is 'length'.

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

99static
E, prefill reuse
0.99
S, prefix stability
1.00
G, generation waste
0.01
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-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.