A provider error is saved as the wiki page, so page retries never run

A wiki generator for any GitHub repository that streams answers from many model providers and already retries a page when its provider call raises an error.
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
- AsyncFuncAI/deepwiki-open
- Commit audited
327da97- leanprompt version
- 0.1.0-dev.15
- Audit date
- Status
- The maintainers have been told about this audit; no response yet.
- Maintainers
- the pull request
- 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 327da97 and found 0 places where its LLM calls could use fewer tokens, plus 4 other problems, not scored. Static score: 100 of 100 (an estimate from the findings). The code may have changed since.
Findings
No open findings.
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.
-
Provider errors are saved as wiki text, so page retries never run
What happens. research_chat turns any provider failure (rate limit, bad key, timeout, context too large) into streamed text (lines 283-287, 278-281). Wiki generation concatenates every chunk (tasks.py:398-400) and stores it, so the error becomes the page body (or 'No valid <wiki_structure> XML found' for the structure step). _generate_page_with_retry (tasks.py:270-285) only retries on exceptions, so its WIKI_PAGE_RETRIES budget never fires for a provider error, and the finished wiki is cached and served by wiki_cache_exists (tasks.py:176-186).
The change. Add a keyword-only raise_errors flag to research_chat (default False, so chat is unchanged) and pass it from the structure and page steps; the existing retry and placeholder then work.
Why it matters. A transient 429 costs a whole page for good, and every page of a rate-limited run can be an error string inside a cached 'completed' wiki.
To check. Make the streamer raise once: with the change the page is generated again on the second attempt; before it the error text is the page content.
-
The Bedrock client returns its errors as a string, which is streamed as the answer
What happens. call() catches every exception around invoke_model (line 357) and returns f'Error: {e}' (line 369). BedrockChatStreamer yields that string as the model's reply (_stream.py:268), so access-denied and throttling reach a wiki page as text, and the @backoff.on_exception decorator at line 301 never sees an exception to retry.
The change. Re-raise inside call() (or return the error in a separate field) so the streamer and the backoff can see it.
To check. Call with an unauthorised model id: the call raises instead of returning a string starting 'Error:'.
-
Bedrock answers are capped at 4,096 tokens and the stop reason is never read
api/clients/bedrock.py:210·LP-GE-12Read the finish reason before using an answer · severity mediumWhat happens. The Claude request body hard-codes max_tokens 4096 (lines 210, 219; 4096 for the other families at 226-239) and _extract_response_text (lines 247-258) returns only content[0].text, never stop_reason. A page that needs more is cut mid-sentence and stored as complete. How often this happens depends on page length.
The change. Read stop_reason ('max_tokens') and retry once with a larger limit, or let the model config set max_tokens.
To check. Ask for a page longer than 4,096 tokens: stop_reason is max_tokens and the stored page ends mid-sentence.
-
Several default and listed model ids are scheduled for or past retirement
api/config/generator.json:45·LP-GE-13Default to a model the provider still serves · severity mediumWhat happens. The openai default is gpt-5-nano (also the openrouter default, line 78); against models/retirements.md (read 2026-11-27) gpt-5-nano is scheduled for 2026-12-11, and listed ids o1, o4-mini, gpt-4, gpt-4-turbo and gpt-35-turbo are retired. The Bedrock default is anthropic.claude-3-sonnet-20240229-v1:0 (line 146), whose Bedrock schedule is not on the Anthropic page. The table was read through a summarising fetch tool and must be re-checked before anyone relies on it.
The change. Update the defaults after checking the providers' own pages.
To check. Compare each id with the provider's deprecations page.
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.