The page leanprompt report --html writes for seratch/ChatGPT-in-Slack at commit 9cbbcea, 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 seratch/ChatGPT-in-Slack

leanprompt audit of seratch/ChatGPT-in-Slack

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.

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

The biggest, at app/openai_ops.py:213, about 108k tokens per 1,000 calls: summaries, proofreading and from-scratch answers are non-streaming calls with timeout=OPENAI_TIMEOUT_SECONDS (30 s, 25 s on Lambda) and the OpenAI client is built without max_retries (openai_api_utils.py:127), so the SDK's default of two retries on a timeout applies.

Together about 178k 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 5 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-GE-04app/openai_ops.py:21390k prompt, 18k output
LP-GE-03app/openai_constants.py:141k output
LP-GE-04app/openai_ops.py:27520k prompt, 8k output
LP-GE-03app/i18n.py:421k output

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

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

Summaries, proofreading and from-scratch answers are non-streaming calls with timeout=OPENAI_TIMEOUT_SECONDS (30 s, 25 s on Lambda) and the OpenAI client is built without max_retries (openai_api_utils.py:127), so the SDK's default of two retries on a timeout applies.

Finding 1. app/openai_ops.py:213 high LP-GE-04 how often is assumed

A summary of a long thread on a medium-effort reasoning model that needs 35 s is sent three times before the user sees the timeout, and on Lambda the 29-second function limit (serverless.yml:48) ends the run during the second attempt.

What to change
Pass max_retries=0 for these calls (or build the client with it), and either stream them like the chat path or give them a longer timeout than the chat reply; on Lambda keep the timeout plus retries below the function limit.
Why it matters
Each timed-out attempt prefills the whole thread again and, if the server finishes it, bills the output that nobody receives.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many summary, proofreading and from-scratch requests raise APITimeoutError, and how many attempts the OpenAI SDK made for each (debug logging of openai shows the retries)
Estimate
about 90k prompt and 18k output tokens per 1,000 calls (estimate, frequency unknown)
What the estimate assumes

15% of calls are summaries, proofreading or from-scratch; 5% of those pass the timeout; a thread summary prompt is about 6,000 tokens; each timeout costs two extra attempts and about 800 output tokens per attempt. OpenAI's Python SDK retries timed-out requests twice by default (its README).

How to check the fix Set OPENAI_TIMEOUT_SECONDS=2 and summarize a long thread with openai debug logging on: before, three POST /chat/completions requests are logged; after, one.

Every chat reply, thread summary, proofreading result and from-scratch answer is capped at a fixed 1,024 completion tokens (MAX_TOKENS, used at openai_ops.py:188).

Finding 2. app/openai_constants.py:1 medium LP-GE-03 how often is assumed

It cannot be changed without editing the code. On the reasoning models in the Home-tab picker that get no reasoning_effort (GPT-5.6 Sol and Terra, GPT-6 Sol and Astra, GPT-6.1 Sol, GPT-5.5, GPT-5, o3), the reasoning tokens come out of the same 1,024, and OpenAI states their default effort is medium.

What to change
Make the budget configurable (an OPENAI_MAX_COMPLETION_TOKENS setting, default for example 4,096 for non-reasoning models and 16,000 or more for reasoning models) and size the context window check from it; or send reasoning_effort low for the reasoning models that accept it.
Why it matters
A reply that hits the cap is cut off mid-sentence or comes back empty. The user asks again, and the bot pays for the cut-off output and resends the whole thread for a second try.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many chat, summary, proofreading and from-scratch replies end with finish_reason length, from the OpenAI usage logs or by logging finish_reason in consume_openai_stream_to_write_reply
Estimate
about 41k output tokens per 1,000 calls in cut-off replies (estimate, frequency unknown)
What the estimate assumes

4% of replies stop at 1,024 tokens (long code answers and proofreading of long Japanese or Chinese text on the default model; more on medium-effort reasoning models); OpenAI's reasoning guide recommends reserving at least 25,000 tokens for reasoning and output when starting out. The re-asked prompt is not counted. The empty-output hint added in PR #122 covers only the fully empty case.

How to check the fix Pick GPT-6 Sol in the Home tab and ask for a 1,500-word answer: before, the reply stops mid-sentence (or shows the empty-output hint) with finish_reason length; after, it completes.

The streaming chat request is created with no timeout (timeout_seconds=None), so the SDK default of 600 s applies until the first chunk.

Finding 3. app/openai_ops.py:275 medium LP-GE-04 how often is assumed

The 30-second limit is checked only when a chunk arrives (openai_ops.py:305), and it covers the whole reply including reasoning time and, after a function call, the follow-up request (line 388). A medium-effort reasoning model that thinks for 25 s gets its answer cut off a few seconds after it starts, and a stalled request is not stopped at 30 s at all.

What to change
Pass a connect and first-byte timeout on the streaming request (for example timeout=httpx.Timeout(OPENAI_TIMEOUT_SECONDS, read=OPENAI_TIMEOUT_SECONDS)), and measure the reply deadline from the first content chunk, or raise the default for reasoning models.
Why it matters
A reply stopped at the deadline was generated and billed up to that point, and the user asks again, resending the thread.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how many chat replies end with the timeout message after part of the answer was shown
Estimate
about 20k prompt and 8k output tokens per 1,000 calls (estimate, frequency unknown)
What the estimate assumes

1% of chat replies pass the deadline mid-stream and are asked again with a 2,000-token thread and about 800 output tokens lost.

How to check the fix Pick GPT-6 Sol and ask a question that needs long reasoning: before, the reply ends with the timeout message shortly after text starts; after, it completes or times out only when no bytes arrive.

The Translate shortcut sends the whole Slack message to translate() with a fixed 1,024-token budget (TRANSLATION_TOKEN_BUDGET) and never reads finish_reason (i18n.py:98).

Finding 4. app/i18n.py:42 low LP-GE-03 how often is assumed

A long message translated into Japanese, Chinese or Korean can need more than 1,024 tokens, and the cut-off translation is also stored in the in-process cache (i18n.py:99), so asking again returns the same cut-off text.

What to change
Size the budget from the input (for example 3x the input tokens, at least 1,024), check finish_reason, and do not cache a result that stopped at length.
Why it matters
The cut-off output is paid for and unusable, and the cache keeps serving it until the process restarts.
How often it happens
The code shows the problem; how often it happens is assumed. To measure it: how often a Translate shortcut result ends with finish_reason length
Estimate
about 1k output tokens per 1,000 calls (estimate)
What the estimate assumes

Translate is a small share of calls; one in a hundred translations is a long message into a CJK language.

How to check the fix Translate a 2,500-character English message into Japanese: before, the result can end mid-sentence; after, it is complete and a second request does not return a cached partial.

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.

A reply cut off at the token limit is shown as if it were complete

Note 1. app/openai_ops.py:397 LP-GE-12 high not scored

consume_openai_stream_to_write_reply records finish_reason (line 315) but uses it only when the text is empty (lines 397-402). A reply that stopped at length with some text is posted as final with no sign it was cut off. The sync paths do the same (lines 644, 705, 752), and the empty-output hint (slack_constants.py:19-22) tells users to increase a completion budget that is a code constant.

What to change
When finish_reason is length and there is text, append a short notice (for example ':warning: The answer was cut off at the token limit.') and, for the hint, name the setting once the budget is configurable.
Same problem as
finding 2

How to check the fix With MAX_TOKENS set to 50 in a test, a fake stream ending with finish_reason length and text produces a final Slack message that carries the notice.

The default image model and the variations model were shut down on 2026-05-12

Note 2. app/env.py:20 LP-GE-13 high not scored

DEFAULT_OPENAI_IMAGE_GENERATION_MODEL is dall-e-3, and image variations are hard-coded to dall-e-2 (openai_image_ops.py:96, bolt_listeners.py:918). OpenAI's deprecations page lists both dall-e-2 and dall-e-3 as shut down on 2026-05-12 (notice 2025-11-14), replaced by gpt-image-2, gpt-image-1 or gpt-image-1-mini. With the default settings the Home-tab image generation and image variations templates now fail on every request.

What to change
Default to gpt-image-1 (or gpt-image-2), drop the style parameter and map quality to low, medium or high, and read b64_json instead of url (the gpt-image models return base64). The variations endpoint was DALL-E 2 only, so remove that template or rebuild it on images.edit.

How to check the fix Run tests/openai_image_ops_test.py with the new default and a fake client that returns b64_json; in a workspace, the image template returns a picture instead of a model_not_found error.

The Home-tab model picker offers models that are already shut down or shut down on 2026-12-11

Note 3. app/slack_ui.py:530 LP-GE-13 medium not scored

build_configure_modal lists gpt-5-chat-latest and gpt-5.1-chat-latest (shut down 2026-07-23), gpt-5.2-chat-latest and gpt-5.3-chat-latest (2026-08-10), and o4-mini (2026-10-23) at lines 510-566, so a workspace that picks one gets an error on every message. gpt-5, gpt-5-mini, gpt-5-nano and o3 shut down on 2026-12-11. Dates from OpenAI's deprecations page, read 2026-11-27.

What to change
Remove the shut-down entries, mark or remove the 2026-12-11 ones, and map saved selections of a retired model to its replacement (gpt-5.6-sol, gpt-5.6-terra, gpt-6.1-sol, gpt-6-luna per the deprecations page).
Already reported
open, outside report: MODEL_FALLBACKS maps gpt-5, o3, gpt-4.1 and gpt-4o to dated snapshots that shut down. It does not mention the picker entries already shut down (chat-latest variants, o4-mini). Note: the app sends the alias, and the fallback map is used only for local token counting and context length. https://github.com/seratch/ChatGPT-in-Slack/issues/155

How to check the fix tests/model_constants_test.py asserts that no picker option is on a list of shut-down ids.

A superseded reply's stream is started and then abandoned unread

Note 4. app/bolt_listeners.py:458 not scored

respond_to_new_message starts the streaming request (line 458) and only then checks whether a newer message arrived (lines 471-480). If one did, it deletes the placeholder and returns (line 486) without reading or closing the stream, so the request is billed for its prompt and whatever the server generates before the connection is dropped.

What to change
Run the conversations_replies check before start_receiving_openai_response, or call stream.close() before returning.

How to check the fix In a unit test with a fake client whose latest reply differs from the placeholder, assert that chat.completions.create is not called (or that close() is called).

The timeout handler makes an LLM call with no timeout

Note 5. app/bolt_listeners.py:249 LP-GE-15 low not scored

After an APITimeoutError or TimeoutError, the handlers translate TIMEOUT_ERROR_MESSAGE for non-English users (lines 249 and 509). translate() calls chat.completions.create with no timeout (i18n.py:95), so when OpenAI is slow the error message itself can wait up to the SDK's 600-second default, and on Lambda it is cut at 29 s, leaving the placeholder.

What to change
Translate the fixed messages once at startup or keep a static per-locale table, or pass a short timeout and fall back to the English text.

How to check the fix With a fake client that sleeps, a timed-out reply for a ja-JP user shows the timeout message within a few seconds.

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-GE-04 at app/openai_ops.py:213: Summaries, proofreading and from-scratch answers are non-streaming calls with timeout=OPENAI_TIMEOUT_SECONDS (30 s, 25 s on Lambda) and the OpenAI client is built without max_retries (openai_api_utils.py:127), so the SDK's default of two retries on a timeout applies. A summary of a long thread on a medium-effort reasoning model that needs 35 s is sent three times before the user sees the timeout, and on Lambda the 29-second function limit (serverless.yml:48) ends the run during the second attempt.
2. LP-GE-03 at app/openai_constants.py:1: Every chat reply, thread summary, proofreading result and from-scratch answer is capped at a fixed 1,024 completion tokens (MAX_TOKENS, used at openai_ops.py:188). It cannot be changed without editing the code. On the reasoning models in the Home-tab picker that get no reasoning_effort (GPT-5.6 Sol and Terra, GPT-6 Sol and Astra, GPT-6.1 Sol, GPT-5.5, GPT-5, o3), the reasoning tokens come out of the same 1,024, and OpenAI states their default effort is medium.
3. LP-GE-04 at app/openai_ops.py:275: The streaming chat request is created with no timeout (timeout_seconds=None), so the SDK default of 600 s applies until the first chunk. The 30-second limit is checked only when a chunk arrives (openai_ops.py:305), and it covers the whole reply including reasoning time and, after a function call, the follow-up request (line 388). A medium-effort reasoning model that thinks for 25 s gets its answer cut off a few seconds after it starts, and a stalled request is not stopped at 30 s at all.
4. LP-GE-03 at app/i18n.py:42: The Translate shortcut sends the whole Slack message to translate() with a fixed 1,024-token budget (TRANSLATION_TOKEN_BUDGET) and never reads finish_reason (i18n.py:98). A long message translated into Japanese, Chinese or Korean can need more than 1,024 tokens, and the cut-off translation is also stored in the in-process cache (i18n.py:99), so asking again returns the same cut-off text.

Other problems found (check each against the code first; not scored):
- A reply cut off at the token limit is shown as if it were complete (app/openai_ops.py:397) [LP-GE-12]: consume_openai_stream_to_write_reply records finish_reason (line 315) but uses it only when the text is empty (lines 397-402). A reply that stopped at length with some text is posted as final with no sign it was cut off. The sync paths do the same (lines 644, 705, 752), and the empty-output hint (slack_constants.py:19-22) tells users to increase a completion budget that is a code constant. Change: When finish_reason is length and there is text, append a short notice (for example ':warning: The answer was cut off at the token limit.') and, for the hint, name the setting once the budget is configurable.
- The default image model and the variations model were shut down on 2026-05-12 (app/env.py:20) [LP-GE-13]: DEFAULT_OPENAI_IMAGE_GENERATION_MODEL is dall-e-3, and image variations are hard-coded to dall-e-2 (openai_image_ops.py:96, bolt_listeners.py:918). OpenAI's deprecations page lists both dall-e-2 and dall-e-3 as shut down on 2026-05-12 (notice 2025-11-14), replaced by gpt-image-2, gpt-image-1 or gpt-image-1-mini. With the default settings the Home-tab image generation and image variations templates now fail on every request. Change: Default to gpt-image-1 (or gpt-image-2), drop the style parameter and map quality to low, medium or high, and read b64_json instead of url (the gpt-image models return base64). The variations endpoint was DALL-E 2 only, so remove that template or rebuild it on images.edit.
- The Home-tab model picker offers models that are already shut down or shut down on 2026-12-11 (app/slack_ui.py:530) [LP-GE-13]: build_configure_modal lists gpt-5-chat-latest and gpt-5.1-chat-latest (shut down 2026-07-23), gpt-5.2-chat-latest and gpt-5.3-chat-latest (2026-08-10), and o4-mini (2026-10-23) at lines 510-566, so a workspace that picks one gets an error on every message. gpt-5, gpt-5-mini, gpt-5-nano and o3 shut down on 2026-12-11. Dates from OpenAI's deprecations page, read 2026-11-27. Change: Remove the shut-down entries, mark or remove the 2026-12-11 ones, and map saved selections of a retired model to its replacement (gpt-5.6-sol, gpt-5.6-terra, gpt-6.1-sol, gpt-6-luna per the deprecations page).
- A superseded reply's stream is started and then abandoned unread (app/bolt_listeners.py:458): respond_to_new_message starts the streaming request (line 458) and only then checks whether a newer message arrived (lines 471-480). If one did, it deletes the placeholder and returns (line 486) without reading or closing the stream, so the request is billed for its prompt and whatever the server generates before the connection is dropped. Change: Run the conversations_replies check before start_receiving_openai_response, or call stream.close() before returning.
- The timeout handler makes an LLM call with no timeout (app/bolt_listeners.py:249) [LP-GE-15]: After an APITimeoutError or TimeoutError, the handlers translate TIMEOUT_ERROR_MESSAGE for non-English users (lines 249 and 509). translate() calls chat.completions.create with no timeout (i18n.py:95), so when OpenAI is slow the error message itself can wait up to the SDK's 600-second default, and on Lambda it is cut at 29 s, leaving the placeholder. Change: Translate the fixed messages once at startup or keep a static per-locale table, or pass a short timeout and fall back to the English text.

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

90static
E, prefill reuse
0.95
S, prefix stability
1.00
G, generation waste
0.16
Default shares
0 of 4

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.