The page leanprompt report --html writes for ZhuLinsen/daily_stock_analysis at commit 88b577e, 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 ZhuLinsen/daily_stock_analysis

leanprompt audit of ZhuLinsen/daily_stock_analysis

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.

The audit found no place where this app pays for tokens it doesn't need

Plus 1 finding the project already knows about (planned, in progress, reported or declined), listed after the findings. They are not in the totals or the score.

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

What's wrong and what to change

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

No confirmed findings.

Already known to the project

The project's own issues, pull requests or docs already cover these, so they are not new and are not in the totals or the score. Read the link before working on one.

When the first reply is cut off at the fixed 8192 cap, the integrity retry resends the prompt plus the cut-off reply with the same cap, so it can be cut off again.

Finding 1. src/analyzer.py:4862 high LP-GE-05

What to change
Known to the project; not proposed again here.
Why it matters
The retry pays for the full prompt and the previous output again.
Already reported
closed PR 2526 (2026-11-14) measured completion_tokens=8192 and an integrity retry that resent the cut-off output with the same cap; the owner asked for a redesign inside report_integrity, not a separate layer https://github.com/ZhuLinsen/daily_stock_analysis/pull/2526
Estimate
not estimated; the project already tracks it
What the estimate assumes

none

How to check the fix See PR 2526.

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.

Usage of earlier attempts is never recorded when a retry or fallback runs

Note 1. src/analyzer.py:4889 LP-GE-11 medium not scored

analyze() calls the model in a loop (integrity retry), and each pass overwrites llm_usage. persist_llm_usage runs once after the loop, so the first call of a retried report is billed by the provider but never written to llm_usage. The same happens inside _call_litellm_impl: a model whose reply fails the JSON check is dropped, and only the model that finally answers returns its usage. The screening ranker and the vision extractor never persist usage at all.

What to change
Persist usage inside the loop and inside the model fallback, after each call returns, with the call_type already used, so every billed call has a row.
Why it matters
get_llm_usage_summary (src/storage.py:4636) sums these rows for the usage report, so retries and fallbacks, the most expensive calls, are the ones missing from it.

How to check the fix Force one integrity retry (REPORT_INTEGRITY_RETRY=1 with a reply missing stop_loss) and check that llm_usage gets two rows for that stock, or one row per fallback model tried.

ANTHROPIC_MAX_TOKENS is documented and editable but no request path reads it

Note 2. src/config.py:2295 LP-GE-17 medium not scored

The setting is in the settings page (validation 256 to 8192) and docs/full-guide.md:298 calls it the maximum response tokens for Claude. config.anthropic_max_tokens is read nowhere else in src. The analysis call uses the literal 8192 (src/analyzer.py:4784) and the single-agent loop sends no cap at all (src/agent/runner.py:563), so the native Anthropic request falls back to 4096 (src/llm/anthropic_transport.py:465).

What to change
Either send config.anthropic_max_tokens as max_tokens on the Anthropic route (analysis and agent), or remove the field and say in the docs that the cap is fixed.
Why it matters
The agent's final answer is the same dashboard JSON the analysis call writes, which the maintainers' own PR 2526 measured at 5,900 to 8,800 characters. A fixed 4096 cap on the Anthropic agent route cuts it with no setting that helps.

How to check the fix Set ANTHROPIC_MAX_TOKENS=2048, run one agent analysis against a stub server and read max_tokens in the request body: today it is absent (or 4096 after the transport default), not 2048.

The agent loop drops the finish reason, so a cut-off answer is a success

Note 3. src/agent/llm_adapter.py:1133 LP-GE-12 medium not scored

The transports parse the stop reason into finish_reason (src/llm/anthropic_transport.py:116, src/llm/openai_transport.py:476), but LLMResponse has no field for it. The runner's final-answer branch (src/agent/runner.py:681) returns success=True with whatever text arrived. A reply stopped by the cap, or tool arguments cut mid-JSON (src/agent/llm_adapter.py:1094 falls back to {"raw": ...}), is treated as finished.

What to change
Add finish_reason to LLMResponse and, in the runner, treat length as unfinished: fail the step or retry once with a larger cap instead of returning the text as the final answer.
Why it matters
Nothing fails: the call succeeds and the report is stored without its last sections.

How to check the fix Stub a reply with finish_reason length and check that the run reports an unfinished answer instead of success.

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.

Already known to the project (read the link first; do not duplicate work the project has planned or started):
- LP-GE-05 (src/analyzer.py:4862): When the first reply is cut off at the fixed 8192 cap, the integrity retry resends the prompt plus the cut-off reply with the same cap, so it can be cut off again. Already reported: closed PR 2526 (2026-11-14) measured completion_tokens=8192 and an integrity retry that resent the cut-off output with the same cap; the owner asked for a redesign inside report_integrity, not a separate layer https://github.com/ZhuLinsen/daily_stock_analysis/pull/2526

Other problems found (check each against the code first; not scored):
- Usage of earlier attempts is never recorded when a retry or fallback runs (src/analyzer.py:4889) [LP-GE-11]: analyze() calls the model in a loop (integrity retry), and each pass overwrites llm_usage. persist_llm_usage runs once after the loop, so the first call of a retried report is billed by the provider but never written to llm_usage. The same happens inside _call_litellm_impl: a model whose reply fails the JSON check is dropped, and only the model that finally answers returns its usage. The screening ranker and the vision extractor never persist usage at all. Change: Persist usage inside the loop and inside the model fallback, after each call returns, with the call_type already used, so every billed call has a row.
- ANTHROPIC_MAX_TOKENS is documented and editable but no request path reads it (src/config.py:2295) [LP-GE-17]: The setting is in the settings page (validation 256 to 8192) and docs/full-guide.md:298 calls it the maximum response tokens for Claude. config.anthropic_max_tokens is read nowhere else in src. The analysis call uses the literal 8192 (src/analyzer.py:4784) and the single-agent loop sends no cap at all (src/agent/runner.py:563), so the native Anthropic request falls back to 4096 (src/llm/anthropic_transport.py:465). Change: Either send config.anthropic_max_tokens as max_tokens on the Anthropic route (analysis and agent), or remove the field and say in the docs that the cap is fixed.
- The agent loop drops the finish reason, so a cut-off answer is a success (src/agent/llm_adapter.py:1133) [LP-GE-12]: The transports parse the stop reason into finish_reason (src/llm/anthropic_transport.py:116, src/llm/openai_transport.py:476), but LLMResponse has no field for it. The runner's final-answer branch (src/agent/runner.py:681) returns success=True with whatever text arrived. A reply stopped by the cap, or tool arguments cut mid-JSON (src/agent/llm_adapter.py:1094 falls back to {"raw": ...}), is treated as finished. Change: Add finish_reason to LLMResponse and, in the runner, treat length as unfinished: fail the step or retry once with a larger cap instead of returning the text as the final answer.

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

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

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

It leaves out 1 finding the project already knows about (planned, in progress, declined or reported); with them it would be 100.

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.