The page leanprompt report --html writes for HKUDS/LightRAG at commit b3ca0dd, audited 2026-11-28. 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 HKUDS/LightRAG

leanprompt audit of HKUDS/LightRAG

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 lightrag/llm/bedrock.py:334, about 1.5M tokens per 1,000 calls: the Bedrock binding sends the system prompt as a plain text block with no cachePoint (bedrock.py:334).

Together about 1.5M 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 3 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-01lightrag/llm/bedrock.py:3341.5M prompt

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

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

The Bedrock binding sends the system prompt as a plain text block with no cachePoint (bedrock.py:334).

Finding 1. lightrag/llm/bedrock.py:334 medium LP-PC-01 how often is assumed

The entity-extraction system prompt is rendered once per run (operate.py:4655/4668) and is the same for every chunk and every gleaning call, about 1.5k tokens. AWS says Claude models on Bedrock do not cache requests without a checkpoint, and the repo's own Bedrock sample model is anthropic.claude-haiku-4-5 (env.example:1914). The Anthropic binding has the same gap (anthropic.py:208) and is already tracked (#4464, open PR #4729).

What to change
Add an opt-in cache_system_prompt argument that appends {"cachePoint": {"type": "default"}} after the system text block, as #4729 does for Anthropic.
Why it matters
Every extraction call pays full input price for the same ~1.5k-token prefix. Claude Haiku 4.5 has a 4,096-token minimum, so the system prompt alone will not cache there; models with a 512 or 1,024 minimum will.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: How many extraction calls the deployment sends to a Bedrock Claude model with a 512 or 1,024 token cache minimum.
Estimate
about 1.5M uncached prompt tokens per 1,000 extraction calls (about 42% of an average call); a cache read bills about a tenth of that on models where the prefix is long enough
What the estimate assumes

system prompt about 1.5k tokens (the maintainers' own tiktoken estimate in #4464), chunk 1,200 tokens, one gleaning call per chunk; Bedrock Claude model whose minimum is at or below 1,024 tokens

How to check the fix Send two extraction calls within five minutes with cache_system_prompt=True and read usage.cacheReadInputTokens on the second; it is non-zero.

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.

Bedrock usage ignores cache reads and writes

Note 1. lightrag/llm/bedrock.py:400 LP-GE-11 medium not scored

Both usage paths pass inputTokens straight to TokenTracker (bedrock.py:400 streaming, :480 non-streaming). Converse reports inputTokens for uncached tokens only; cache reads and writes arrive in cacheReadInputTokens and cacheWriteInputTokens (AWS prompt caching page). With caching on (e.g. BEDROCK_LLM_EXTRA_FIELDS with a top-level cache_control, bedrock.py:356-358), prompt_tokens drops to the uncached remainder and the cache share is never reported. OpenAI and Gemini bindings already report cached_prompt_tokens (#4572, #4687).

What to change
prompt_tokens = inputTokens + cacheReadInputTokens + cacheWriteInputTokens; report cacheReadInputTokens as cached_prompt_tokens.

How to check the fix Feed a Converse usage block with cacheReadInputTokens to a TokenTracker: prompt_tokens includes it and get_usage() shows cached_prompt_tokens.

Public Claude 3 helpers name retired models

Note 2. lightrag/llm/anthropic.py:462 LP-GE-13 low not scored

claude_3_opus_complete, claude_3_sonnet_complete and claude_3_haiku_complete hard-code claude-3-opus-20240229 (:462), claude-3-sonnet-20240229 (:483) and claude-3-haiku-20240307 (:504). Anthropic's deprecations page lists them retired on 2026-01-05, 2025-07-21 and 2026-04-20; requests return 404. Library helpers only: the server does not use the Anthropic binding and nothing but a test calls them.

What to change
Remove the three helpers or point them at a current model; use anthropic_complete with LLM_MODEL instead.

How to check the fix grep for claude-3- under lightrag/ returns nothing.

Responses binding drops cached prompt tokens

Note 3. lightrag/llm/openai_responses.py:358 LP-GE-11 low not scored

_usage_counts forwards input, output and total tokens only, so a run through the OpenAI Responses binding shows no cached_prompt_tokens in the TokenTracker, while the Chat Completions binding does since #4572.

What to change
Read usage.input_tokens_details.cached_tokens and forward it as cached_prompt_tokens, keeping a reported zero.

How to check the fix A mocked Responses usage with input_tokens_details.cached_tokens=5 gives cached_prompt_tokens 5 in the tracker; absent or null details leave the field out.

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-01 at lightrag/llm/bedrock.py:334: The Bedrock binding sends the system prompt as a plain text block with no cachePoint (bedrock.py:334). The entity-extraction system prompt is rendered once per run (operate.py:4655/4668) and is the same for every chunk and every gleaning call, about 1.5k tokens. AWS says Claude models on Bedrock do not cache requests without a checkpoint, and the repo's own Bedrock sample model is anthropic.claude-haiku-4-5 (env.example:1914). The Anthropic binding has the same gap (anthropic.py:208) and is already tracked (#4464, open PR #4729).

Other problems found (check each against the code first; not scored):
- Bedrock usage ignores cache reads and writes (lightrag/llm/bedrock.py:400) [LP-GE-11]: Both usage paths pass inputTokens straight to TokenTracker (bedrock.py:400 streaming, :480 non-streaming). Converse reports inputTokens for uncached tokens only; cache reads and writes arrive in cacheReadInputTokens and cacheWriteInputTokens (AWS prompt caching page). With caching on (e.g. BEDROCK_LLM_EXTRA_FIELDS with a top-level cache_control, bedrock.py:356-358), prompt_tokens drops to the uncached remainder and the cache share is never reported. OpenAI and Gemini bindings already report cached_prompt_tokens (#4572, #4687). Change: prompt_tokens = inputTokens + cacheReadInputTokens + cacheWriteInputTokens; report cacheReadInputTokens as cached_prompt_tokens.
- Public Claude 3 helpers name retired models (lightrag/llm/anthropic.py:462) [LP-GE-13]: claude_3_opus_complete, claude_3_sonnet_complete and claude_3_haiku_complete hard-code claude-3-opus-20240229 (:462), claude-3-sonnet-20240229 (:483) and claude-3-haiku-20240307 (:504). Anthropic's deprecations page lists them retired on 2026-01-05, 2025-07-21 and 2026-04-20; requests return 404. Library helpers only: the server does not use the Anthropic binding and nothing but a test calls them. Change: Remove the three helpers or point them at a current model; use anthropic_complete with LLM_MODEL instead.
- Responses binding drops cached prompt tokens (lightrag/llm/openai_responses.py:358) [LP-GE-11]: _usage_counts forwards input, output and total tokens only, so a run through the OpenAI Responses binding shows no cached_prompt_tokens in the TokenTracker, while the Chat Completions binding does since #4572. Change: Read usage.input_tokens_details.cached_tokens and forward it as cached_prompt_tokens, keeping a reported zero.

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

74static
E, prefill reuse
0.58
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-28 (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.