Every reply is capped at 1,024 tokens, and a cut-off answer is posted as whole

A Slack bot for OpenAI and Azure OpenAI that adds new models within days and already tells users when a reasoning reply comes back empty.
≈ 41,000 tokens per 1,000 calls, in replies cut off at the fixed 1,024-token cap estimate
Audited with leanprompt 0.1.0-dev.15
Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.
- Repository
- seratch/ChatGPT-in-Slack
- Commit audited
9cbbcea- leanprompt version
- 0.1.0-dev.15
- Audit date
- Status
- The maintainers have been told about this audit; no response yet.
- Maintainers
- the issue
- How it ran
- 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.
A Slack bot for OpenAI and Azure OpenAI that chats in threads, summarises, proofreads and translates. Every reply is capped at a fixed 1,024 completion tokens, reasoning included, and a reply cut off with some text is posted as final; the default image models were shut down in May 2026. Figures are estimates from the code.
leanprompt read the code at commit 9cbbcea and found 4 places where its LLM calls could use fewer tokens, plus 5 other problems, not scored. Static score: 90 of 100 (an estimate from the findings). The code may have changed since.
Findings
-
LP-GE-04Stream long outputs; timeouts that match generation timeapp/openai_ops.py:213· severity high · saves prefill and generation · how often is assumedWhat happens. 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.
The 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 helps. Each timed-out attempt prefills the whole thread again and, if the server finishes it, bills the output that nobody receives.
Estimate about 90k prompt and 18k output tokens per 1,000 calls (estimate, frequency unknown)
Assumptions. 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 often. 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)
-
LP-GE-03Output and thinking budgets that fit the taskapp/openai_constants.py:1· severity medium · saves generation · how often is assumedWhat happens. 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.
The 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 helps. 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.
Estimate about 41k output tokens per 1,000 calls in cut-off replies (estimate, frequency unknown)
Assumptions. 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 often. 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
-
LP-GE-04Stream long outputs; timeouts that match generation timeapp/openai_ops.py:275· severity medium · saves prefill and generation · how often is assumedWhat happens. 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.
The 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 helps. A reply stopped at the deadline was generated and billed up to that point, and the user asks again, resending the thread.
Estimate about 20k prompt and 8k output tokens per 1,000 calls (estimate, frequency unknown)
Assumptions. 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 often. how many chat replies end with the timeout message after part of the answer was shown
-
LP-GE-03Output and thinking budgets that fit the taskapp/i18n.py:42· severity low · saves generation · how often is assumedWhat happens. 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.
The 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 helps. The cut-off output is paid for and unusable, and the cache keeps serving it until the process restarts.
Estimate about 1k output tokens per 1,000 calls (estimate)
Assumptions. Translate is a small share of calls; one in a hundred translations is a long message into a CJK language.
How often. how often a Translate shortcut result ends with finish_reason length
Other problems the audit found
Problems read in the code that cost no tokens of their own, such as a cost meter or an error path. Not scored.
-
A reply cut off at the token limit is shown as if it were complete
app/openai_ops.py:397·LP-GE-12Read the finish reason before using an answer · severity high · the same problem as finding 2What happens. 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.
The 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.
To check. 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
app/env.py:20·LP-GE-13Default to a model the provider still serves · severity highWhat happens. 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.
The 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.
To check. 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
app/slack_ui.py:530·LP-GE-13Default to a model the provider still serves · severity mediumWhat happens. 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.
The 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
To check. 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
What happens. 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.
The change. Run the conversations_replies check before start_receiving_openai_response, or call stream.close() before returning.
To check. 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
app/bolt_listeners.py:249·LP-GE-15Give each timeout one meaning, and set one · severity lowWhat happens. 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.
The 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.
To check. With a fake client that sleeps, a timed-out reply for a ja-JP user shows the timeout message within a few seconds.
The maintainers’ response
No response from the maintainers yet.
How this was made
The llm-call-audit skill read the code and wrote findings.json; nothing was run against the project’s providers. The full audit page is what leanprompt report --html writes from the same findings.
Corrections and takedown: email info@podwarden.com or open an issue.