The page leanprompt report --html writes for koala73/worldmonitor at commit 32833c8, audited 2026-11-30. Every figure on this page is an estimate from reading the code, not a measurement of the app in use. Corrections and takedown: email info@podwarden.com or open an issue. Back to the audit of koala73/worldmonitor

leanprompt audit of koala73/worldmonitor

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.

1 place where this app pays for tokens it doesn't need

The biggest, at scripts/ais-relay.cjs:16204, about 10k tokens per run: the widget agent switches tool_choice from auto to none on its last turns, after the tools have run.

Together about 10k tokens per run (one widget-agent request (1 to 10 model turns)) An estimate from the code, not a measurement.

Tokens per run (one widget-agent request (1 to 10 model turns)), by finding, and each one's share of the total

Plus 2 other problems the audit found, listed after the findings. Not scored.

What this costs you

Every figure here is an estimate from the code, not a measurement. Findings can overlap (one failed call can show up in two), so the sum may count some tokens twice. Money is not part of the score. The table lists this app's findings first, largest first, then its open questions, then the questions for the server's administrator, then the findings the project already knows about, which are not in the totals.

A run is one widget-agent request (1 to 10 model turns). Per-run figures are a separate total, never added to the figures per 1,000 calls.

FindingWhereTokens per run
LP-PC-05scripts/ais-relay.cjs:1620410k not cached; the fix writes 10k to the cache at the write price

To see this in money, add to leanprompt.yaml:

  • prices: per model: input, cached_input and output per 1M tokens (US dollars, or set currency), with source and checked date (or, self-hosted, engine: {prefill_tokens_per_second: N})

leanprompt never guesses a volume or a price. Your coding agent can look up the provider's current price page and add it with the date; how.

What's wrong and what to change

1 open, 0 fixed. Largest first, by the audit's estimate of tokens lost per 1,000 calls, then per run.

The widget agent switches tool_choice from auto to none on its last turns, after the tools have run.

Finding 1. scripts/ais-relay.cjs:16204 medium LP-PC-05 how often is assumed

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.

What to 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 matters
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.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: 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.
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)
What the estimate assumes

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 to check the fix Compare cache_read_input_tokens on the none turn before and after keeping tool_choice at auto; the none turn should read the earlier turns from cache.

Other problems the audit found

Problems the audit checked in the code that cost no tokens of their own, such as a spend meter that ignores cache tokens or a cut-off answer accepted as complete. They are not scored. Check each one before you change anything.

Summaries cut off at the 100-token limit are cached for 24 hours as if whole

Note 1. server/worldmonitor/news/v1/summarize-article.ts:579 LP-GE-12 high not scored

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.

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

How to check the fix 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.

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

Note 2. server/_shared/llm.ts:186 LP-GE-13 medium not scored

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.

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

How to check the fix 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.

Fix it with your coding agent

Paste this into Claude Code, Codex, Cursor or any coding assistant. It will check each finding against your code and propose fixes one at a time, asking before it changes anything.

Please check and fix the LLM-call findings from a leanprompt audit of this repository.

1. If the leanprompt skills are not installed for you here, install them: npx leanprompt@0.1.0-dev.15 install
2. Read .leanprompt/findings.json and leanprompt-report.md. If they are missing, use the list below.
3. Check each finding against the code before you change anything. The audit can be wrong: if a finding does not hold, tell me why and leave that code alone.
4. Fix one finding at a time. Show me the change as a small diff and apply it only after I say yes.
5. Prove each fix with the measure-loop skill: a before and after on the same scenario. Ask me before running anything that sends real, billed requests.
6. When a fix is proved, set "fixed": true on its finding in .leanprompt/findings.json and run npx leanprompt@0.1.0-dev.15 score.

Findings, largest first:
1. LP-PC-05 at scripts/ais-relay.cjs:16204: 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.

Other problems found (check each against the code first; not scored):
- 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]: 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. 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.
- 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]: 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. Change: Require LLM_MODEL when LLM_API_URL is set (return null and log once), or default to a model that is still served.

Score

One number from 0 to 100 for how well this app avoids paying for the same tokens twice; higher is better. It is computed from the findings above (static) or from your usage log (measured).

99static
E, prefill reuse
0.99
S, prefix stability
1.00
G, generation waste
0.00
Default shares
0 of 1

Findings scored with severity defaults, not estimates. The fewer, the more the static score says about this app.

A static score is an estimate from the audit's findings, not a measurement.

Scored 2026-11-30 (the date on the machine that ran it).

Questions for the owner

These were not answered during the audit. Until they are, the page shows tokens only and ranks the advice without a priority.

  • Priority: which matters most for this app, cost, speed or quality (or weights)? Not set, so the advice uses equal weights. Answer with priority: in leanprompt.yaml.
  • Volume: how many calls does the app make a month? Answer with volume: {calls_per_month: N, source: "..."} in leanprompt.yaml.
  • Prices: what does each model cost (input, cached input, output per 1M tokens, with the source and the date it was read, and the currency if not US dollars)? Answer with prices: in leanprompt.yaml.