News summaries cut off at 100 tokens are cached for a day as if complete

Cut-off answer Reported

A real-time global intelligence dashboard with AI news summaries; its shared LLM chain already checks for answers that stop at the limit.

The mistake: Cut-off answerAPPArticle summaries,28 languagesREQUESTOutput limit:max_tokens 100 forevery summaryREPLYCut off at thelimitTHENSaved and cachedfor 24 hours as afull summaryfinish_reason is never readThe mistake: Cut-off answerAPPArticle summaries,28 languagesREQUESTOutput limit:max_tokens 100 forevery summaryREPLYCut off at thelimitTHENSaved and cachedfor 24 hours as afull summaryfinish_reason is never readThe mistake: Cut-off answerAPPArticle summaries, 28 languagesREQUESTOutput limit: max_tokens 100 forevery summaryREPLYCut off at the limitTHENSaved and cached for 24 hours asa full summaryfinish_reason is never read

≈ 10,000 tokens per 1,000 calls, no token figure; how often the cut-off happens is not known 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
koala73/worldmonitor 91.3k GitHub stars
Commit audited
32833c8
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 32833c8 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-PC-05 Tool lists grow only at the end

    scripts/ais-relay.cjs:16204 · severity medium · saves prefill · how often is assumed

    What happens. The widget agent switches tool_choice from auto to none on its last turns, after the tools have run. The Anthropic caching doc says a tool_choice change invalidates the cached messages, so that turn reads none of the conversation from cache and writes it again.

    The change. Keep tool_choice at auto for the whole request. The loop already rejects any tool call made while finalizing (ais-relay.cjs:16266) and sends a 'Tools are now disabled' message, so enforcement does not need the switch.

    Why it helps. On the turn after the switch, the system prompt and tools still hit the cache but the search and page results, history and any modified HTML are processed again at the cache-write price instead of the cache-read price. That prefix can be 5k to 40k tokens.

    Estimate about 10,000 prompt tokens per widget request that reaches a tool_choice none turn, read at the write price instead of the read price (estimate)

    Assumptions. one affected turn per request; tool results are capped at 20,000 characters each (ais-relay.cjs:15440), up to 3 or 4 results, plus up to 12 history lines of 500 characters; requests that finish before the tool budget or the last two turns never switch; widget requests are a small share of the app's prompt tokens, so share is 0.01 (estimate).

    How often. On a widget request that reaches a tool_choice none turn, whether usage.cacheRead drops to the system and tools prefix only; the request already logs cacheWrite and cacheRead per request at ais-relay.cjs:16134.

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. Summaries cut off at the 100-token limit are cached for 24 hours as if whole

    server/worldmonitor/news/v1/summarize-article.ts:579 · LP-GE-12 Read the finish reason before using an answer · severity high

    What happens. summarize-article sends max_tokens 100 (summarize-article.ts:555 and :532) for summaries in 28 output languages and never reads finish_reason. A reply that stops at the limit is checked only for length over 20 characters and for reasoning preamble, then stored for 24 hours (CACHE_TTL_SECONDS, _shared.ts:5) and served as a finished summary. The same shape is in deduct-situation.ts:192 (1,500 tokens, stored 3,600 s) and in the non-English country brief at get-country-intel-brief.ts:656.

    The change. Read choices[0].finish_reason on the direct path and treat 'length' as a failed attempt (do not cache it), and pass retryOnLengthLimit: true on the callLlm path at summarize-article.ts:527 and in the other two callers. The repo already does this in llm-chain.cjs:272 and brief-why-matters.ts:266.

    Why it matters. A truncated 'two sentence' summary looks complete to the reader and is then served from the cache for a day to every caller with the same headlines. Prompts ask for under 60 words, which is close to 100 tokens in English and above it in many of the other output languages.

    To check. Force a 20-token limit in a test, check that a length-stopped reply is not written to the cache and that the next provider is tried.

  2. The generic provider falls back to gpt-3.5-turbo, which OpenAI retired on 2026-10-23

    server/_shared/llm.ts:186 · LP-GE-13 Default to a model the provider still serves · severity medium

    What happens. With LLM_API_URL and LLM_API_KEY set and LLM_MODEL left empty, which is how .env.example:383 ships it, the request names gpt-3.5-turbo. The OpenAI deprecations page, captured 2026-11-28, lists gpt-3.5-turbo with a shutdown of Oct 23, 2026 and gpt-5.6-terra as the replacement.

    The change. Require LLM_MODEL when LLM_API_URL is set (return null and log once), or default to a model that is still served.

    Why it matters. An OpenAI-compatible endpoint that is OpenAI itself will refuse the model, and the provider chain records a failed attempt on every call instead of saying the model name is missing.

    To check. Set only LLM_API_URL and LLM_API_KEY and check that the provider is skipped with a clear log line, or that a current model id is sent.

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.