Website research resends a cut-off answer unchanged

Cut-off answer Reported

An open source SEO tool for keyword research, rank tracking and site audits, with an MCP server so an agent can use the same data.

The mistake: Cut-off answerAPPopen-seoREQUESTOutput limit: 6000tokens, reasoningincludedREPLYCut off at thelimitTHENSame request runagainup to 2 morefinishReason is never looked atThe mistake: Cut-off answerAPPopen-seoREQUESTOutput limit: 6000tokens, reasoningincludedREPLYCut off at thelimitTHENSame request runagainup to 2 morefinishReason is never looked atThe mistake: Cut-off answerAPPopen-seoREQUESTOutput limit: 6000 tokens,reasoning includedREPLYCut off at the limitTHENSame request run againup to 2 morefinishReason is never looked at

≈ 15,000 tokens per 1,000 runs, tokens for the answers and searches resent after a cut-off reply estimate

Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.

Repository
every-app/open-seo
Commit audited
6f68494
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 6f68494 and found 1 place where its LLM calls could use fewer tokens, plus 2 other problems, not scored. Static score: 99 of 100 (an estimate from the findings). The code may have changed since.

Findings

  1. LP-GE-05 Retry only retryable errors; never retry a truncation unchanged

    src/server/features/projects/services/websiteResearch.ts:58 · severity medium · saves prefill and generation · how often is assumed

    What happens. 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.

    The 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 helps. 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.

    Estimate up to about 6,000 output tokens plus a full tool loop per wasted attempt, at most two attempts per run (estimate)

    Assumptions. 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 often. How often generateText throws NoObjectGeneratedError with finishReason 'length' in website research, from the Workers logs or the seo spend rows.

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.

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

    src/server/features/sam/SamChatAgent.ts:426 · LP-GE-11 Meter every billed token, cached and unfinished ones too · severity low

    What happens. 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.

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

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

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

    src/server/features/sam/SamChatAgent.ts:253 · LP-GE-15 Give each timeout one meaning, and set one · severity medium

    What happens. 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.

    The 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'.

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

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.