Every item's prompt carries the seller's whole rating and listing history

A second-hand listing monitor that scrapes with a browser and analyses each item with a multimodal model, caching the seller profile it scrapes.
≈ 3,500,000 tokens per 1,000 calls, prompt tokens for the seller's whole rating and listing lists, sent again for each item estimate
Audited with leanprompt 0.1.0-dev.15
Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.
- Repository
- Usagi-org/ai-goofish-monitor
- Commit audited
77f8d75- leanprompt version
- 0.1.0-dev.15
- Audit date
- Status
- The maintainers have been told about this audit; no response yet.
- Maintainers
- the issue
- How it ran
- 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.
leanprompt read the code at commit 77f8d75 and found 1 place where its LLM calls could use fewer tokens, plus 3 other problems, not scored. Static score: 89 of 100 (an estimate from the findings). The code may have changed since.
Findings
-
LP-PD-04Trim tool results and retrieved context at the tool boundarysrc/ai_handler.py:314· severity high · saves prefill · size is assumedWhat happens. 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.
The 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 helps. 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.
Estimate about 3.5M prompt tokens per 1,000 items (estimate)
Assumptions. 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 big. 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
Other problems the audit found
Problems read in the code that cost no tokens of their own, such as a cost meter or an error path. 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-15Give each timeout one meaning, and set one · severity mediumWhat happens. 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().
The 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.
To check. 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
src/ai_handler.py:407·LP-GE-12Read the finish reason before using an answer · severity highWhat happens. finish_reason / status is never read, and the same 4000-token request is repeated up to 4 times.
The 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
To check. 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
src/services/item_analysis_dispatcher.py:131·LP-GE-12Read the finish reason before using an answer · severity mediumWhat happens. After 4 failed attempts the item is stored with is_recommended false and its link is then treated as already processed on later runs.
The 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
To check. Make the first run fail, fix the key, run again: the item is analysed.
The maintainers’ response
No response from the maintainers yet.
How this was made
The llm-call-audit skill read the code and wrote findings.json; nothing was run against the project’s providers. The full audit page is what leanprompt report --html writes from the same findings.
Corrections and takedown: email info@podwarden.com or open an issue.