fix(retriever): cap per-document content so small local models can finish a report#27
Merged
Merged
Conversation
…nish a report The StealthRetriever fed full Bypassed pages into the synthesis prompt, so a 16k-context local model overflowed (~56k–68k tokens) and the report step never ran — only the 🛡️ badge was written. This broke the README's "local-first, no API key" promise on a typical small local model. Cap each document to `max_chars` (default 2000) before it reaches the research loop. Verified live against a local 16k llama-server (Qwen) + SearXNG: the same run that previously errored now Bypasses 20 Cloudflare/Turnstile walls AND writes a substantive cited report (prompt dropped 68k -> well under 16k). Pure `_cap_content` helper is unit-tested (langchain-free, CI-safe). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The
StealthRetrieverreturned each Bypassed page's full text as the LangChainDocument.page_content. The research loop then stuffed all of them into the synthesis prompt, so a small-context local model overflowed before it could write anything:The result: only the
🛡️ Bypassed Nbadge was written, no report body, no citations. This silently broke the README's "local-first, no API key required" + "cited report" promise for anyone running a typical small local model.The fix
Cap each document to
max_chars(default 2000) before it reaches the loop. New pure helper_cap_content(langchain-free → unit-testable in CI, which installs--no-deps).Verified live (not mocked)
Same machine, local 16k-context
llama-server(Qwen3.6-35B) + SearXNG, identical query:[1]…[28]The bypass/Evidence layer was always real; this makes the report step actually complete on small local models.
Tests
tests/test_retriever.py— 3 cases for_cap_content(long capped, short untouched,0/Nonedisables).ruffclean.🤖 Generated with Claude Code