The page leanprompt report --html writes for infinmalum/a1o-platform at commit 1e44601, 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 infinmalum/a1o-platform
leanprompt audit of infinmalum/a1o-platform
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.
6 places where this app pays for tokens it doesn't need
The biggest, at agent/context.go:352, about 1.2M tokens per 1,000 calls: once a Studio chat passes the context budget, every new turn makes an extra summarising call with its own system prompt over the whole older transcript.
Togetherabout 4.3M tokens per 1,000 calls An estimate from the code, not a measurement. Findings that overlap are counted once.
Tokens per 1,000 calls, by finding, and each one's share of the total
Plus 5 other problems the audit found, listed after the findings. Not scored.
This project is a gateway or proxy. 5 items are about the gateway's own calls, 6 items about what it does to its clients' calls; each card says which.
What this costs you
Every figure here is an estimate from the code, not a measurement. Findings the audit marked as overlapping are counted once in the totals, the largest of each group; other findings can still overlap. 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.
Finding
Where
Tokens per 1,000 calls
LP-PC-08 (the gateway's own calls)
agent/context.go:352
1.2M prompt, 30k output
LP-PC-01 (the gateway's own calls)
relay/bridge/responses_anthropic.go:197
1.2M not cached; the fix writes 216k to the cache at the write price
LP-PC-01 (clients' calls through the gateway)
relay/bridge/chat_anthropic.go:184
1.1M not cached; the fix writes 270k to the cache at the write price
LP-PC-12 (clients' calls through the gateway)
model/ability.go:109
600k not cached
LP-PC-06 (the gateway's own calls)
agent/context.go:281
300k not cached
LP-PC-06 (the gateway's own calls)
agent/skills.go:62
120k 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
6 open, 0 fixed. Largest first, by the audit's estimate of tokens lost per 1,000 calls.
1
Once a Studio chat passes the context budget, every new turn makes an extra summarising call with its own system prompt over the whole older transcript.
Finding 1. agent/context.go:352mediumLP-PC-08how often is assumedthe gateway's own calls
The summary is stored but older messages are never marked as done: the next turn loads all messages again (model/chat.go:270), is over the budget again, and summarises the same history again, plus the previous summary.
What to change
Load only the messages after CompactedThrough, keep the stored summary, and summarise only when the uncompacted tail passes the budget again; run the summary as a continuation of the same instructions, tools and history so it reads the cache.
Why it matters
The summariser re-reads tens of thousands of tokens of history on every turn and writes up to 1,536 output tokens that the next turn throws away and recomputes.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: How many Studio chat turns run in sessions whose estimated context exceeds ChatContextBudgetTokens (32,000 by default): count context_compacted run events per session; more than one per session (one per turn) confirms the repeat.
Overlaps
Finding 5 loses some of the same tokens; the totals count the larger once.
Estimate
about 1.2M prompt tokens and 30k output tokens per 1,000 calls (estimate)What the estimate assumes
Studio chat turns are 20% of calls (two legs per turn on average); 15% of those turns are in sessions past the 32k budget, so 3% of calls trigger a summariser call; each re-reads about 40k tokens of older transcript (messages cut at 4,000 characters) and writes about 1,000 tokens.
2
When a Responses-format request goes to a Claude channel, the converter builds the Anthropic request with no cache mark at all.
Finding 2. relay/bridge/responses_anthropic.go:197highLP-PC-01how often is assumedthe gateway's own calls
Studio's own agent (Chat, Work, subagents) uses exactly this path for every claude-* model (agent/executor.go:326-327 prefers the Anthropic wire). Anthropic caches nothing without a mark, so on every leg of the agent loop the instructions, tools and whole history are billed at the full input price again.
What to change
In the converter, add Anthropic's top-level automatic cache mark ({"cache_control":{"type":"ephemeral"}}) to the request it builds, or marks on the last tool, the system text and the newest message. Bedrock rejects the top-level form, so on AwsClaude channels use block-level marks.
Why it matters
An agent leg resends everything the previous leg sent plus one tool result. Without a mark the provider recomputes all of it at the full input price instead of about a tenth of it.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: Share of model calls that go Responses-wire to an Anthropic, Bedrock-Claude or Vertex-Claude channel: every Studio Chat/Work/subagent leg on a claude-* model, plus API clients of /v1/responses on Claude. Read it from the consume log by channel type and from model_invocations.upstream_protocol = anthropic.
Estimate
about 1.2M prompt tokens per 1,000 calls billed uncached that the cache could serve (estimate)What the estimate assumes
40% of calls are Studio agent legs, 30% of those on Claude (12% of all calls); average prompt 12k tokens, 85% of it repeated from the previous leg or turn; legs return within seconds, well inside the 5-minute lifetime, so marks pay back (break-even (1.25-1)/(1-0.1) = 0.28 reads per write). Cache writes of the new tail (~1.8k per call) at 1.25x are listed as cache_write.
3
OpenAI-format clients routed to a Claude channel go through this converter, which never adds a cache mark, and a client cannot add one either: extra keys on a message or a text part (such as cache_control) are rejected (relay/bridge/chat_anthropic.go:32, relay/bridge/chat_common.go:128).
Finding 3. relay/bridge/chat_anthropic.go:184highLP-PC-01how often is assumedclients' calls through the gateway
So every Chat Completions request that reaches Claude through the gateway is billed at the full input price, however much it repeats.
What to change
Add the top-level automatic cache mark to the converted request (block-level marks on Bedrock), optionally behind a channel setting, and accept cache_control on text parts so clients that already mark can keep their marks.
Why it matters
A chat or agent client resends its whole history each turn; on Claude only a marked prefix is read from the cache at a tenth of the price.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: Share of /v1/chat/completions traffic that lands on Anthropic, AwsClaude or Vertex-Claude channels (controller/relay.go:48-59), and how much of it is multi-turn, from the consume log.
Estimate
about 1.1M prompt tokens per 1,000 calls billed uncached that the cache could serve (estimate)What the estimate assumes
15% of all calls are Chat Completions requests bridged to Claude; average prompt 12k tokens, 60% of it repeated from the client's previous request within 5 minutes; new tail ~1.8k per call written at 1.25x (cache_write).
4
Each request picks a channel at random among the same-priority channels for the model (model/ability.go:109, model/cache.go:299), with no memory of the conversation.
Finding 4. model/ability.go:109mediumLP-PC-12how often is assumedclients' calls through the gateway
Studio's agent does the same per leg (agent/executor.go:146). When those channels are different provider accounts, consecutive requests of one conversation hit different caches, and most of them start cold.
What to change
Choose the channel once per conversation (hash a session, conversation or prompt_cache_key value, or the client's token and first message, onto the eligible channels) and fall back to another only on error.
Why it matters
Anthropic and OpenAI never share a cache between organisations (Anthropic also not between workspaces), so splitting one conversation over N accounts leaves about (N-1)/N of its requests without a cache hit.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: Whether the deployment serves one model through two or more channels of the same priority that use different provider organisations or workspaces; and, from the consume log, how often consecutive requests of one conversation land on different channels.
Estimate
about 600k prompt tokens per 1,000 calls not served from cache (estimate)What the estimate assumes
30% of calls are for models served by two equal-priority channels on different accounts, so half of their continuing requests miss; about 4k reusable tokens per such request. Zero on a deployment with one account per model.
5
In a long Studio chat the kept history is recomputed every turn as the newest messages that fit in two fifths of the budget, so the conversation the model sees starts at a different message on every turn.
Finding 5. agent/context.go:281mediumLP-PC-06how often is assumedthe gateway's own calls
Everything after the instructions and tools is new to the provider's cache on each turn's first leg.
What to change
Keep a fixed compaction boundary (CompactedThrough) between compactions, so the history after it only grows at the end until the next compaction.
Why it matters
A prefix cache reuses only an unchanged start; moving the start of the history each turn forfeits the reuse of up to 12,800 tokens of history per turn.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: Same as the compaction finding: the number of chat turns in sessions past the context budget, and the upstream cached tokens on the first leg of those turns on an automatic-cache provider (OpenAI, Gemini).
Overlaps
Finding 1 loses some of the same tokens; the totals count the larger once.
Estimate
about 300k prompt tokens per 1,000 calls not served from cache (estimate)What the estimate assumes
3% of calls are first legs of turns in sessions past the budget; about 10k tokens of kept history per such leg would otherwise be read from an automatic cache (OpenAI, Gemini). On Claude nothing is cached today anyway (finding responses-claude-no-marks).
6
After the model loads a Skill, its instructions are appended as an extra user message at the very end of the input on every following leg.
Finding 6. agent/skills.go:62mediumLP-PC-06how often is assumedthe gateway's own calls
Each leg adds the new tool call and result before them, so the instructions move back one step each time and are recomputed on every leg.
What to change
Insert the loaded instructions once, at the point in the history where the Skill was loaded (right after its tool result), and keep them there for the rest of the turn.
Why it matters
Content that moves is never part of the unchanged prefix, so the skill text is billed uncached on every leg after it loads.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: How often a Studio turn loads a Skill and how long its instructions are (skills import up to 64 KiB): count Skill tool calls in tool_executions and the instruction length of the skills they load.
Estimate
about 120k prompt tokens per 1,000 calls not served from cache (estimate)What the estimate assumes
10% of Studio legs (4% of calls) run after a Skill was loaded; about 3k tokens of instructions per leg would otherwise be cached by an automatic-cache provider.
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.
N1
The code bills cache reads and writes at the full input price
Note 1. relay/billing/native.go:142LP-GE-11mediumnot scoredclients' calls through the gateway
The quota charged is (Input + Output x completion ratio) x model ratio x group ratio, and Input includes cache reads and cache writes (relay/native/usage.go:78). The price book has only an input price and an output ratio per model (relay/billing/ratio/model.go:24-29), and the OpenRouter price sync reads only prompt and completion (controller/channel_models.go:343-346). So the code bills cache reads, which providers price at a fraction of input, at the full input price, and Anthropic cache writes (1.25x or 2x) at 1x.
What to change
Add cached-input and cache-write prices per model (sync them from OpenRouter's input_cache_read and input_cache_write), and charge Input minus CacheRead minus CacheCreation at the input price, CacheRead and CacheCreation at their own prices.
Why it matters
Worked example (estimate; assumes the operator's ratios equal Anthropic's list prices): a coding-agent request of 100k input tokens (95k cache reads, 3k 5-minute writes, 2k uncached) and 1k output priced at 5x input. The provider's bill is 9.5k + 3.75k + 2k + 5k = 20.25k input-token equivalents; the code charges 100k + 5k = 105k, about 5x. List prices, checked 2026-11-26: Anthropic reads 0.1x input by default, writes 1.25x (5 minutes) or 2x (1 hour) (platform.claude.com, prompt caching); OpenAI reads 0.25x or 0.5x by model (OpenRouter's provider notes).
N2
The compaction summary never reaches the model
Note 2. agent/engine.go:212not scoredthe gateway's own calls
compactIfNeeded stores a summary in session.Summary and drops the older messages from the working history, but the leg input is built from the reference files and the kept messages only (agent/engine.go:207-221); session.Summary is read only by the token estimate and by the next summariser call (agent/context.go:265, 328-331). Past the budget the model sees only the last ~12,800 tokens of the chat, though a summary call was made for it. A design note the project later removed (commit 31df916a) lists history plus summary as the context builder's job and repeated summary billing as forbidden.
What to change
Put the summary in the input as the first message after the instructions (not in the instructions, so the head stays cached), and load only messages after CompactedThrough.
OpenAI-format requests to Claude are capped at 1,024 output tokens when no limit is sent
Note 3. relay/bridge/chat_anthropic.go:24not scoredclients' calls through the gateway
Anthropic requires max_tokens, so when a Chat Completions or Responses client omits its limit the converters set 1024 (relay/bridge/chat_anthropic.go:24, relay/bridge/responses_anthropic.go:41; reservation at controller/native.go:126-128). On OpenAI the omitted limit means the model's maximum, so the same client gets answers cut at 1,024 tokens on Claude channels. The cut is reported faithfully as finish_reason length.
What to change
Default to the model's maximum output (or an operator setting per channel) instead of 1024, and document the default.
N4
Some successful Claude replies become a 502 and are charged at the reservation
Note 4. relay/bridge/chat_anthropic.go:248LP-GE-12highnot scoredclients' calls through the gateway
The non-streaming Chat converter rejects stop_reason refusal (the streaming one maps it, relay/bridge/stream.go:170), and all four Anthropic-to-OpenAI converters reject model_context_window_exceeded (chat_anthropic.go:248, stream.go:176, stream_responses_anthropic.go:346, responses_anthropic.go:447). The upstream reply was generated and billed, but the client gets a 502 and the gateway settles with no usage, which keeps the reservation (relay/lifecycle/forward.go:410-414, relay/billing/native.go:147-150), not the provider's figures.
What to change
Map refusal to finish_reason content_filter (or stop with the refusal text) and model_context_window_exceeded to length, and settle failed conversions from the usage in the upstream body.
N5
Strict field lists block common clients on cross-protocol routes
Note 5. relay/bridge/chat_common.go:25not scoredclients' calls through the gateway
Converters reject unknown fields instead of dropping them. That is safe for semantics, but it also rejects cache hints whose loss is harmless: Anthropic requests with cache_control on a block or tool fail when routed to an OpenAI-chat, Responses or Gemini upstream (relay/bridge/anthropic_chat.go:77 and 186, anthropic_responses.go:154, messages_gemini.go:121), and Chat requests to Claude or Gemini channels fail on stream_options, user or parallel_tool_calls (chat_common.go:25; only the Responses converter accepts stream_options, chat_responses.go:29).
What to change
Accept and drop cache_control when the upstream caches automatically, accept stream_options.include_usage on every Chat converter (the stream already reports usage), and list the rejected fields in the docs.
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-08 at agent/context.go:352 [the gateway's own calls]: Once a Studio chat passes the context budget, every new turn makes an extra summarising call with its own system prompt over the whole older transcript. The summary is stored but older messages are never marked as done: the next turn loads all messages again (model/chat.go:270), is over the budget again, and summarises the same history again, plus the previous summary.
2. LP-PC-01 at relay/bridge/responses_anthropic.go:197 [the gateway's own calls]: When a Responses-format request goes to a Claude channel, the converter builds the Anthropic request with no cache mark at all. Studio's own agent (Chat, Work, subagents) uses exactly this path for every claude-* model (agent/executor.go:326-327 prefers the Anthropic wire). Anthropic caches nothing without a mark, so on every leg of the agent loop the instructions, tools and whole history are billed at the full input price again.
3. LP-PC-01 at relay/bridge/chat_anthropic.go:184 [clients' calls through the gateway]: OpenAI-format clients routed to a Claude channel go through this converter, which never adds a cache mark, and a client cannot add one either: extra keys on a message or a text part (such as cache_control) are rejected (relay/bridge/chat_anthropic.go:32, relay/bridge/chat_common.go:128). So every Chat Completions request that reaches Claude through the gateway is billed at the full input price, however much it repeats.
4. LP-PC-12 at model/ability.go:109 [clients' calls through the gateway]: Each request picks a channel at random among the same-priority channels for the model (model/ability.go:109, model/cache.go:299), with no memory of the conversation. Studio's agent does the same per leg (agent/executor.go:146). When those channels are different provider accounts, consecutive requests of one conversation hit different caches, and most of them start cold.
5. LP-PC-06 at agent/context.go:281 [the gateway's own calls]: In a long Studio chat the kept history is recomputed every turn as the newest messages that fit in two fifths of the budget, so the conversation the model sees starts at a different message on every turn. Everything after the instructions and tools is new to the provider's cache on each turn's first leg.
6. LP-PC-06 at agent/skills.go:62 [the gateway's own calls]: After the model loads a Skill, its instructions are appended as an extra user message at the very end of the input on every following leg. Each leg adds the new tool call and result before them, so the instructions move back one step each time and are recomputed on every leg.
Other problems found (check each against the code first; not scored):
- The code bills cache reads and writes at the full input price (relay/billing/native.go:142) [LP-GE-11] [clients' calls through the gateway]: The quota charged is (Input + Output x completion ratio) x model ratio x group ratio, and Input includes cache reads and cache writes (relay/native/usage.go:78). The price book has only an input price and an output ratio per model (relay/billing/ratio/model.go:24-29), and the OpenRouter price sync reads only prompt and completion (controller/channel_models.go:343-346). So the code bills cache reads, which providers price at a fraction of input, at the full input price, and Anthropic cache writes (1.25x or 2x) at 1x. Change: Add cached-input and cache-write prices per model (sync them from OpenRouter's input_cache_read and input_cache_write), and charge Input minus CacheRead minus CacheCreation at the input price, CacheRead and CacheCreation at their own prices.
- The compaction summary never reaches the model (agent/engine.go:212) [the gateway's own calls]: compactIfNeeded stores a summary in session.Summary and drops the older messages from the working history, but the leg input is built from the reference files and the kept messages only (agent/engine.go:207-221); session.Summary is read only by the token estimate and by the next summariser call (agent/context.go:265, 328-331). Past the budget the model sees only the last ~12,800 tokens of the chat, though a summary call was made for it. A design note the project later removed (commit 31df916a) lists history plus summary as the context builder's job and repeated summary billing as forbidden. Change: Put the summary in the input as the first message after the instructions (not in the instructions, so the head stays cached), and load only messages after CompactedThrough.
- OpenAI-format requests to Claude are capped at 1,024 output tokens when no limit is sent (relay/bridge/chat_anthropic.go:24) [clients' calls through the gateway]: Anthropic requires max_tokens, so when a Chat Completions or Responses client omits its limit the converters set 1024 (relay/bridge/chat_anthropic.go:24, relay/bridge/responses_anthropic.go:41; reservation at controller/native.go:126-128). On OpenAI the omitted limit means the model's maximum, so the same client gets answers cut at 1,024 tokens on Claude channels. The cut is reported faithfully as finish_reason length. Change: Default to the model's maximum output (or an operator setting per channel) instead of 1024, and document the default.
- Some successful Claude replies become a 502 and are charged at the reservation (relay/bridge/chat_anthropic.go:248) [LP-GE-12] [clients' calls through the gateway]: The non-streaming Chat converter rejects stop_reason refusal (the streaming one maps it, relay/bridge/stream.go:170), and all four Anthropic-to-OpenAI converters reject model_context_window_exceeded (chat_anthropic.go:248, stream.go:176, stream_responses_anthropic.go:346, responses_anthropic.go:447). The upstream reply was generated and billed, but the client gets a 502 and the gateway settles with no usage, which keeps the reservation (relay/lifecycle/forward.go:410-414, relay/billing/native.go:147-150), not the provider's figures. Change: Map refusal to finish_reason content_filter (or stop with the refusal text) and model_context_window_exceeded to length, and settle failed conversions from the usage in the upstream body.
- Strict field lists block common clients on cross-protocol routes (relay/bridge/chat_common.go:25) [clients' calls through the gateway]: Converters reject unknown fields instead of dropping them. That is safe for semantics, but it also rejects cache hints whose loss is harmless: Anthropic requests with cache_control on a block or tool fail when routed to an OpenAI-chat, Responses or Gemini upstream (relay/bridge/anthropic_chat.go:77 and 186, anthropic_responses.go:154, messages_gemini.go:121), and Chat requests to Claude or Gemini channels fail on stream_options, user or parallel_tool_calls (chat_common.go:25; only the Responses converter accepts stream_options, chat_responses.go:29). Change: Accept and drop cache_control when the upstream caches automatically, accept stream_options.include_usage on every Chat converter (the stream already reports usage), and list the rejected fields in the docs.
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).
81static
E, prefill reuse
0.69
S, prefix stability
1.00
G, generation waste
0.00
Default shares
0 of 6
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.
If this helped
If this page saved you some digging, a star or a word to a colleague helps other builders find it.
leanprompt checked how our app calls LLMs and found 6 places where it pays for tokens it doesn't need, about 4.3M tokens per 1,000 calls, an estimate from the code. It explains each finding in plain English and hands the fixes to your coding agent. It is free, open source, and runs locally: https://github.com/Podwarden/leanprompt
The README badge
The badge needs a public repository on GitHub, GitLab.com or Bitbucket with .leanprompt/score.json committed: shields.io reads the file from there. This repository's remote is not one of those, so there is no snippet to paste.