The page leanprompt report --html writes for 666ghj/MiroFish at commit 7657031, audited 2026-11-27. 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 666ghj/MiroFish

leanprompt audit of 666ghj/MiroFish

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.

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

The biggest, at backend/app/services/report_agent.py:622, about 9k tokens per run: the section-writing system prompt names the section being written on line 622, before about 3,000 tokens of instructions and the tool list that are the same for every section.

Together about 11k tokens per run (one report generation: outline, 2-5 sections, tool-side calls; about 15-40 calls) An estimate from the code, not a measurement.

Tokens per run (one report generation: outline, 2-5 sections, tool-side calls; about 15-40 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.

A run is one report generation: outline, 2-5 sections, tool-side calls; about 15-40 calls. Per-run figures are a separate total, never added to the figures per 1,000 calls.

FindingWhereTokens per run
LP-PC-03backend/app/services/report_agent.py:6229k not cached
LP-PD-06backend/app/services/zep_tools.py:15992.2k prompt

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

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

The section-writing system prompt names the section being written on line 622, before about 3,000 tokens of instructions and the tool list that are the same for every section.

Finding 1. backend/app/services/report_agent.py:622 medium LP-PC-03

Each section therefore starts with a different prompt, and the provider cannot reuse the shared text from the previous section.

What to change
Remove the section title from the system prompt template. The user prompt template already names the section (line 780), so nothing is lost. Keep the report title, summary and scenario lines where they are.
Why it matters
The first call of every section after the first pays full price for about 3,000 tokens it paid for a minute earlier. The later calls inside one section already share the prompt.
Who reaches this
every report with 2 or more sections
Estimate
about 9,000 uncached prompt tokens per report (estimate)
What the estimate assumes

3 of 4 sections miss the cache, 3,000 tokens of static text after the title (about 3,150 characters of Chinese plus the tool list); qwen-plus implicit cache (1,024-token minimum per the Alibaba table) or OpenAI automatic caching; share is of the report path only (about 22 calls, 9,000 prompt tokens each), not the simulation calls made through camel-ai, which were not read.

How to check the fix Generate a two-section report and log usage.prompt_tokens_details.cached_tokens on the first call of section 2: it rises from near 0 to roughly 3,000.

The agent-selection prompt lists every simulated agent with json.dumps(indent=2), so each interested_topics entry goes on its own indented line.

Finding 2. backend/app/services/zep_tools.py:1599 low LP-PD-06 size is assumed

What to change
Use separators=(',', ':') and no indent, or one line per agent.
Why it matters
Line breaks and indentation are tokens; with 100 agents it adds roughly a fifth to the list.
How big it is
The code shows the problem and how often it happens; how many tokens it costs each time is assumed. To measure it: how many agents a typical simulation has; the cost scales with it
Estimate
about 2,200 prompt tokens per interview_agents call at 100 agents (estimate)
What the estimate assumes

100 agents at about 110 tokens each, 20 percent whitespace overhead, one interview_agents call per report.

How to check the fix Count prompt_tokens for the selection call before and after with the same 100 profiles: it drops by about a fifth of the agent list.

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.

chat() never reads the finish reason, so a cut-off report section is saved as finished

Note 1. backend/app/utils/llm_client.py:156 LP-GE-12 high not scored

chat() returns the cleaned text without looking at finish_reason. The report section loop calls it with max_tokens=4096 (report_agent.py:1344 and :1550) and stores any answer as the section, so a section that hit the limit is written as complete.

What to change
Raise on finish_reason == 'length' in chat(), as chat_json() already does at line 242.
In progress
Open PR 'never save an empty report section from an unusable LLM response' makes chat() reject length stops and drops the cap on retry. https://github.com/666ghj/MiroFish/pull/841

How to check the fix Mock a completion with finish_reason 'length' and check chat() raises.

Interview summary is capped at 800 tokens but asked to be up to 1000 characters

Note 2. backend/app/services/zep_tools.py:1727 LP-GE-12 medium not scored

The prompt says the summary must stay within 1000 characters (line 1704) but the call sends max_tokens=800. A thousand Chinese characters is more than 800 tokens, so a full-length summary is cut mid-sentence, and chat() does not check the finish reason, so the cut text goes into the report as a tool result.

What to change
Raise the cap to about 2,000 tokens (or word the limit in tokens), and check the finish reason (see the chat() note).
Why it matters
A truncated summary of the interviews is what the report writer then quotes from.

How to check the fix Feed 10 interview answers of 500 characters each and check the summary ends on a full stop and finish_reason is stop.

Cut-off persona and config JSON is closed with brackets and accepted

Note 3. backend/app/services/oasis_profile_generator.py:589 LP-GE-12 medium not scored

When finish_reason is length the code closes the open strings and brackets (_fix_truncated_json) and parses the result as a complete persona. The same pattern is in simulation_config_generator.py:460. A persona cut in the middle becomes a shorter persona with no warning beyond a log line, and in the config version the agents after the cut are likely to fall back to rule-based defaults without a warning.

What to change
On length, retry once (the bounded retry already exists in the loop) or fall back to the rule-based profile, rather than repairing and returning. For the config batch, check that every agent_id of the batch is present before accepting.
Why it matters
The simulation then runs on truncated personas and partial configs that look valid.

How to check the fix Mock a length stop mid-persona and check the generator retries or falls back instead of returning the repaired text.

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-03 at backend/app/services/report_agent.py:622: The section-writing system prompt names the section being written on line 622, before about 3,000 tokens of instructions and the tool list that are the same for every section. Each section therefore starts with a different prompt, and the provider cannot reuse the shared text from the previous section.
2. LP-PD-06 at backend/app/services/zep_tools.py:1599: The agent-selection prompt lists every simulated agent with json.dumps(indent=2), so each interested_topics entry goes on its own indented line.

Other problems found (check each against the code first; not scored):
- chat() never reads the finish reason, so a cut-off report section is saved as finished (backend/app/utils/llm_client.py:156) [LP-GE-12]: chat() returns the cleaned text without looking at finish_reason. The report section loop calls it with max_tokens=4096 (report_agent.py:1344 and :1550) and stores any answer as the section, so a section that hit the limit is written as complete. Change: Raise on finish_reason == 'length' in chat(), as chat_json() already does at line 242.
- Interview summary is capped at 800 tokens but asked to be up to 1000 characters (backend/app/services/zep_tools.py:1727) [LP-GE-12]: The prompt says the summary must stay within 1000 characters (line 1704) but the call sends max_tokens=800. A thousand Chinese characters is more than 800 tokens, so a full-length summary is cut mid-sentence, and chat() does not check the finish reason, so the cut text goes into the report as a tool result. Change: Raise the cap to about 2,000 tokens (or word the limit in tokens), and check the finish reason (see the chat() note).
- Cut-off persona and config JSON is closed with brackets and accepted (backend/app/services/oasis_profile_generator.py:589) [LP-GE-12]: When finish_reason is length the code closes the open strings and brackets (_fix_truncated_json) and parses the result as a complete persona. The same pattern is in simulation_config_generator.py:460. A persona cut in the middle becomes a shorter persona with no warning beyond a log line, and in the config version the agents after the cut are likely to fall back to rule-based defaults without a warning. Change: On length, retry once (the bounded retry already exists in the loop) or fall back to the rule-based profile, rather than repairing and returning. For the config batch, check that every agent_id of the batch is present before accepting.

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

96static
E, prefill reuse
0.94
S, prefix stability
1.00
G, generation waste
0.00
Default shares
0 of 2

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