The page leanprompt report --html writes for wyattlindsey/rootwise at commit ff18600, audited 2026-11-26. 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 wyattlindsey/rootwise

leanprompt audit of wyattlindsey/rootwise

3 places where this app pays for tokens it doesn't need

The biggest, at lib/model/client.ts:60, about 1.2M tokens per 1,000 calls: only the system prompt carries a cache mark.

Together about 1.4M tokens per 1,000 calls An estimate from the code, not a measurement.

Tokens per 1,000 calls, 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.

FindingWhereTokens per 1,000 calls
LP-PC-01lib/model/client.ts:601.2M not cached
LP-GE-04app/api/chat/route.ts:15137k prompt, 9.3k output
LP-PC-07lib/chat/system-prompt.ts:9457k not cached

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

  • volume: {calls_per_month: N}: how many calls the app makes a month (with targets:, on each entry)
  • 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

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

Only the system prompt carries a cache mark.

Finding 1. lib/model/client.ts:60 medium LP-PC-01

Inside one question the tool loop calls the model again after every tool round, and each call resends the question, the model's earlier tool requests and every tool result so far. None of that part is marked, so it is never read from the cache and is paid at the full input price on every round.

What to change
Also mark the newest message: at send time, add cache_control {type: 'ephemeral'} to the last content block of the last message (or set the request-level automatic cache_control). Keep the stored history unchanged. Update the budget meter to count cache writes and reads at the same time (see the notes).
Why it matters
Each tool round extends the previous request byte for byte, so with a mark on the newest message the next round reads everything before its new tool results from cache at 0.1x the input price instead of paying full price again.
Estimate
about 1.2M prompt tokens per 1,000 calls not served from cache (estimate)
What the estimate assumes

3 model calls per question (two tool rounds and the answer, as route.ts:13 and :33 describe); about 10k uncached input tokens per question, inferred from the 5-7 cents per question in route.ts:33 at the prices in lib/budget/pricing.ts; tool rounds of about 3k tokens each; the 3.5k-token tools and system head is already cached. A heavy question (README.md:80, about 40k input) loses proportionally more.

How to check the fix Run one question that makes two tool rounds. Before: cache_read_input_tokens on rounds 2 and 3 equals the head (about 3.5k). After: it rises by the size of the earlier messages (about 0.3k on round 2, about 3.3k on round 3), and input_tokens falls by the same amount.

A whole question, up to 8 model calls at high effort with adaptive thinking and a 16,000-token output limit each, must finish inside one 60-second function.

Finding 2. app/api/chat/route.ts:15 low LP-GE-04 how often is assumed

If it does not, the function is stopped: the visitor gets a cut-off answer, the tokens already generated are paid for, and the budget meter never records them because the done event is never sent.

What to change
Measure first. If questions come near 60 seconds, either raise maxDuration (the plan allows it) or lower the output and effort settings for later rounds; and record usage after every model call rather than only on done.
Why it matters
Tokens generated before the function is stopped are billed and thrown away, and a visitor who gets no answer usually asks again, paying for the whole question twice.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: The p95 duration of a whole question (all tool rounds) in production, compared with maxDuration = 60 seconds. Vercel's function logs show runs that hit the limit.
Estimate
about 137k prompt and 9k output tokens per 1,000 calls (estimate, if 2% of questions hit the limit)
What the estimate assumes

2% of questions exceed 60 seconds (unknown; the comment at lib/model/client.ts:7-10 shows the author watches p95 latency); a cut-off question has cost 20.5k prompt and 1.4k output tokens and is asked again.

How to check the fix Count function runs that end at 60 seconds over a week before and after; each should end with a done event and a usage record.

The visitor's coordinates (line 94) and today's date (line 54) are inside the one system block that carries the cache mark.

Finding 3. lib/chat/system-prompt.ts:94 low LP-PC-07 how often is assumed

Two visitors with different locations therefore never share the cached tools and instructions, and the date changes the block once a day.

What to change
Split the system prompt into two blocks: the fixed instructions first with the cache mark, then a short second block with the date and the location line and no mark. Alternatively put a mark on the last tool as well.
Why it matters
A cache entry is found only for the exact bytes up to the mark, so one changed coordinate in the last paragraph makes the whole 3.5k-token head a miss for that visitor.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: How often a visitor starts a conversation within 5 minutes of another visitor's request, and how often their shared location (or the UTC date) differs. Read it from the Vercel request log or the app's budget store timestamps.
Estimate
about 57k prompt tokens per 1,000 calls (estimate, depends on traffic)
What the estimate assumes

6 calls per conversation (two questions of three calls), so 167 first calls per 1,000; 10% of them start within the 5-minute cache lifetime of another visitor with a different location or date; about 3.4k tokens would be shared. At the demo's stated traffic (about 15 questions a day) the real figure is close to zero.

How to check the fix Two first questions from two different locations within 5 minutes: before, the second reports cache_creation_input_tokens of about 3.5k; after, it reports cache_read_input_tokens of about 3.4k.

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.

The daily budget meter undercounts spend

Note 1. lib/budget/pricing.ts:9 not scored

costCents is fed message.usage.input_tokens and output_tokens only (lib/chat/run.ts:98). On Anthropic input_tokens counts only the tokens after the last cache breakpoint, so cache writes (billed at 1.25x) and cache reads (0.1x) never reach the meter, and the daily cap can be overspent by about a third.

What to change
Pass cache_creation_input_tokens and cache_read_input_tokens to the meter and price each at its own rate.
Why it matters
The cap is what keeps the public demo inside its budget. Adding cache marks to the agent loop moves more tokens into the cache fields and widens the gap.

How to check the fix For one question, the meter's cents match the sum of the three input fields and the output at the prices in lib/budget/pricing.ts.

Questions that end without done are not metered

Note 2. lib/chat/handle-chat-request.ts:156 not scored

recordUsage runs only on a done event. A question that hits the 8-round limit, errors, is refused after partial output or is aborted has been billed but is never counted.

What to change
Record usage after every model call (or in a finally block), not only on done.

How to check the fix Abort a question after the first tool round: the budget store shows that round's tokens.

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.13 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.13 score.

Findings, largest first:
1. LP-PC-01 at lib/model/client.ts:60: Only the system prompt carries a cache mark. Inside one question the tool loop calls the model again after every tool round, and each call resends the question, the model's earlier tool requests and every tool result so far. None of that part is marked, so it is never read from the cache and is paid at the full input price on every round.
2. LP-GE-04 at app/api/chat/route.ts:15: A whole question, up to 8 model calls at high effort with adaptive thinking and a 16,000-token output limit each, must finish inside one 60-second function. If it does not, the function is stopped: the visitor gets a cut-off answer, the tokens already generated are paid for, and the budget meter never records them because the done event is never sent.
3. LP-PC-07 at lib/chat/system-prompt.ts:94: The visitor's coordinates (line 94) and today's date (line 54) are inside the one system block that carries the cache mark. Two visitors with different locations therefore never share the cached tools and instructions, and the date changes the block once a day.

Other problems found (check each against the code first; not scored):
- The daily budget meter undercounts spend (lib/budget/pricing.ts:9): costCents is fed message.usage.input_tokens and output_tokens only (lib/chat/run.ts:98). On Anthropic input_tokens counts only the tokens after the last cache breakpoint, so cache writes (billed at 1.25x) and cache reads (0.1x) never reach the meter, and the daily cap can be overspent by about a third. Change: Pass cache_creation_input_tokens and cache_read_input_tokens to the meter and price each at its own rate.
- Questions that end without done are not metered (lib/chat/handle-chat-request.ts:156): recordUsage runs only on a done event. A question that hits the 8-round limit, errors, is refused after partial output or is aborted has been billed but is never counted. Change: Record usage after every model call (or in a finally block), not only on done.

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

87static
E, prefill reuse
0.80
S, prefix stability
1.00
G, generation waste
0.02
Default shares
0 of 3

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-26 (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.