The page leanprompt report --html writes for Usagi-org/ai-goofish-monitor at commit 77f8d75, 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 Usagi-org/ai-goofish-monitor

leanprompt audit of Usagi-org/ai-goofish-monitor

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/ai_handler.py:314, about 3.5M tokens per 1,000 calls: each item's prompt contains the seller's whole rating list and whole listing list, because the profile scraper scrolls until the site says there is no next page.

Together about 3.5M 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 3 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-04src/ai_handler.py:3143.5M prompt

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.

Each item's prompt contains the seller's whole rating list and whole listing list, because the profile scraper scrolls until the site says there is no next page.

Finding 1. src/ai_handler.py:314 high LP-PD-04 size is assumed

Every entry also carries fields the criteria never use (rating id, rating image URLs, listing id, listing image URL, the seller avatar URL), and the JSON is pretty-printed with indent=2.

What to change
Where the prompt JSON is built, drop the id and URL fields from the seller lists, serialise compactly, and optionally cap the lists to the newest N entries (a setting, default unlimited so answers do not change).
Why it matters
Seller entries are about 100 tokens each, about half of it ids, URLs and indentation. The block is sent again for every item of the same seller, because only the scraping is cached (SellerProfileCache), not the prompt.
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: prompt_tokens of one analysis request (provider usage) for an item whose seller has about 40 ratings and 40 listings, before and after the change
Estimate
about 3.5M prompt tokens per 1,000 items (estimate)
What the estimate assumes

A seller with 40 ratings and 40 listings (the size in the project's own log in issue 146), about 100 tokens per entry, about 45 percent of it ids, URLs and whitespace; the average call is about 20,000 prompt tokens (up to 9 images, the seller block, about 3,000 tokens of instructions, the item JSON). Larger sellers cost proportionally more; the cap would be a separate, optional change.

How to check the fix Log usage.prompt_tokens for the same item before and after: the drop should match the removed fields. Compare the model's reason and criteria_analysis for 10 stored items; the seller_type verdicts should not change.

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.

No timeout on the analysis client; SDK retries inside the app's 4 attempts, with no pause

Note 1. src/config.py:77 LP-GE-15 medium not scored

AsyncOpenAI is built with only api_key and base_url. The openai SDK then waits up to 600 s for a reply and retries a failed request twice. get_ai_analysis wraps that in 4 attempts with no pause between them, so one item can send up to 12 identical requests (each with every image as base64) and hold one of the 2 analysis slots for up to 2 hours; scraper.py waits for all slots at dispatcher.join().

What to change
Pass timeout=httpx.Timeout(120, connect=10) and max_retries=0 (or 1) to AsyncOpenAI, and sleep a few seconds between the app's own attempts. The settings test-connection client already sets timeout=30 s (src/api/routes/settings.py:302); the analysis client does not.
Why it matters
A hung gateway stalls the whole task; a 429 or 5xx is retried immediately, up to 12 times.

How to check the fix Point OPENAI_BASE_URL at a local server that never answers: the item should fail after about the configured timeout, not after 10 minutes.

A reply cut off at max_tokens is not detected as cut off

Note 2. src/ai_handler.py:407 LP-GE-12 high not scored

finish_reason / status is never read, and the same 4000-token request is repeated up to 4 times.

What to change
Reject length / incomplete replies and retry once with a larger limit.
In progress
open PR 535 adds IncompleteAIResponseError and AI_MAX_OUTPUT_TOKENS; PR 518 and 525 do part of it; issues 499 and 519 describe it https://github.com/Usagi-org/ai-goofish-monitor/pull/535

How to check the fix Request with max tokens 50: the item is retried or reported, not parsed.

A failed analysis is saved as a final not-recommended result and never retried

Note 3. src/services/item_analysis_dispatcher.py:131 LP-GE-12 medium not scored

After 4 failed attempts the item is stored with is_recommended false and its link is then treated as already processed on later runs.

What to change
Do not store (or mark for retry) results whose analysis errored.
Already reported
open issue 477 asks to re-run failed analyses; the maintainer replied there is no per-item re-run; open PR 513 adds delete of failed items https://github.com/Usagi-org/ai-goofish-monitor/issues/477

How to check the fix Make the first run fail, fix the key, run again: the item is analysed.

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 src/ai_handler.py:314: Each item's prompt contains the seller's whole rating list and whole listing list, because the profile scraper scrolls until the site says there is no next page. Every entry also carries fields the criteria never use (rating id, rating image URLs, listing id, listing image URL, the seller avatar URL), and the JSON is pretty-printed with indent=2.

Other problems found (check each against the code first; not scored):
- No timeout on the analysis client; SDK retries inside the app's 4 attempts, with no pause (src/config.py:77) [LP-GE-15]: AsyncOpenAI is built with only api_key and base_url. The openai SDK then waits up to 600 s for a reply and retries a failed request twice. get_ai_analysis wraps that in 4 attempts with no pause between them, so one item can send up to 12 identical requests (each with every image as base64) and hold one of the 2 analysis slots for up to 2 hours; scraper.py waits for all slots at dispatcher.join(). Change: Pass timeout=httpx.Timeout(120, connect=10) and max_retries=0 (or 1) to AsyncOpenAI, and sleep a few seconds between the app's own attempts. The settings test-connection client already sets timeout=30 s (src/api/routes/settings.py:302); the analysis client does not.
- A reply cut off at max_tokens is not detected as cut off (src/ai_handler.py:407) [LP-GE-12]: finish_reason / status is never read, and the same 4000-token request is repeated up to 4 times. Change: Reject length / incomplete replies and retry once with a larger limit.
- A failed analysis is saved as a final not-recommended result and never retried (src/services/item_analysis_dispatcher.py:131) [LP-GE-12]: After 4 failed attempts the item is stored with is_recommended false and its link is then treated as already processed on later runs. Change: Do not store (or mark for retry) results whose analysis errored.

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

89static
E, prefill reuse
0.83
S, prefix stability
1.00
G, generation waste
0.00
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.