OpenAI-compatible answers cut off at the token limit are saved as if complete

A grey desk printer feeds out a receipt with printed bars, and the torn-off half, cut across its bars, lies in a tray beside a green check mark.

Cut-off answer Reported

A browser extension that streams answers from 15+ providers and already flags cut-off Claude replies.

≈ 100,000 tokens per 1,000 calls, for answers cut off at the 2,000-token default and asked again estimate

Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.

Repository
ChatGPTBox-dev/chatGPTBox
Commit audited
be0d714
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 browser extension that puts a chat box, selection tools and page summaries on every site, calling 15+ providers. On the OpenAI-compatible path an answer cut off at the 2,000-token default is saved and shown as finished; the Claude path already reports it. Figures are estimates from the code.

leanprompt read the code at commit be0d714 and found 3 places where its LLM calls could use fewer tokens, 1 more that costs no tokens today, plus 4 other problems, not scored. Static score: 84 of 100 (an estimate from the findings). The code may have changed since.

Findings

  1. LP-PC-01 Put cache marks where the provider needs them

    src/services/apis/claude-api.mjs:31 · severity high · saves prefill

    What happens. The Claude API request body has no cache_control anywhere, so Anthropic caches nothing. Every follow-up question about a summarised page or video resends the whole earlier conversation, including the page text, at the full input price.

    The change. Add top-level automatic caching to the body: cache_control: { type: 'ephemeral' }. Anthropic then places the breakpoint on the last cacheable block and moves it forward each turn.

    Why it helps. A Summarize Page or video prompt is up to about 5,900 tokens after cropText; with marks, each follow-up within 5 minutes reads it at 0.1x (0.05x on Opus 5.5 and Sonnet 5.5) instead of 1x.

    Estimate about 450k prompt tokens per 1,000 calls not served from cache (estimate)

    Assumptions. 15% of calls go to the Claude API, half of them are follow-ups within 5 minutes carrying about 6,000 tokens of earlier conversation; default-enabled Claude models (Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5) have a 512-token minimum; the first call of each conversation pays the 1.25x write on about 6,000 tokens. Searched issues and PRs for cache_control and prompt caching: nothing.

  2. LP-PC-06 Append-only history

    src/services/apis/openai-compatible-core.mjs:95 · severity high · saves prefill

    What happens. History is cut to the last maxConversationContextLength question/answer pairs (9 by default) on every request (also claude-api.mjs:26 and azure-openai-api.mjs:21). From the tenth turn on, each request starts with a different pair, so the provider's cache cannot reuse any of the history, and the first turn, which holds the page or video text of a summary, is dropped from the conversation.

    The change. Drop old turns in larger steps (for example keep the first pair and cut back to 5 pairs when 9 is reached), so the prefix stays the same for several turns, and keep the first pair of a summary conversation.

    Why it helps. Each turn past the window recomputes the whole history at full price.

    Estimate about 240k prompt tokens per 1,000 calls not served from cache (estimate)

    Assumptions. 3% of calls are turn 10 or later of a conversation with about 8,000 tokens of history; automatic caching on OpenAI and Gemini, marks on Claude (finding claude-marks).

  3. LP-GE-03 Output and thinking budgets that fit the task

    src/services/apis/openai-compatible-core.mjs:99 · severity medium · saves generation · how often is assumed

    What happens. Every OpenAI-compatible request is capped at Max Response Token Length, 2,000 by default (src/config/index.mjs:861), and the default-enabled OpenAI modes are reasoning models whose default effort is medium. On Chat Completions the cap covers the hidden reasoning as well as the visible answer, so a page summary can stop part-way or before any visible text, and the app then shows it as a finished answer (see the note on line 148).

    The change. Treat finish_reason "length" as a cut-off (the note below), and raise the default limit for reasoning models, for example 16,000 for GPT-5.x/GPT-6.x and Gemini 3.x, or send a lower reasoning_effort for short tasks.

    Why it helps. A cut-off answer is paid for in full (reasoning and visible tokens), and the user asks again with the same 2,000-token limit, which tends to stop at the same place.

    Estimate about 100k output tokens per 1,000 calls (estimate, frequency unknown)

    Assumptions. 5% of all calls are OpenAI-compatible reasoning-model calls that hit the 2,000-token limit and are asked again; each loses the full 2,000 output tokens; 700 output tokens per average call. OpenAI's reasoning guide recommends reserving at least 25,000 tokens for reasoning and output when starting out (read 2026-11-27); GPT-6.1 Terra and GPT-6.1 Sol default to medium effort. Related, not the same: open issue #1133 / PR #1134 are about the parameter's name, not its size.

    How often. how many OpenAI-compatible answers end with finish_reason "length" on the default-enabled GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, GPT-6 Astra and Gemini 3.x modes, from the provider's request logs

  4. LP-GE-04 Stream long outputs; timeouts that match generation time

    src/utils/fetch-sse.mjs:71 · severity medium · saves prefill and generation · costs no tokens today

    What happens. No request has a timeout: fetchSSE passes only the Stop button's AbortController, so a provider that accepts the connection and never sends a byte leaves the answer spinning until the user presses Stop.

    The change. Add a first-byte timeout (for example 60 seconds, longer for reasoning models) with AbortSignal.any([controller.signal, AbortSignal.timeout(ms)]), cleared when the first chunk arrives, and report it as a timeout rather than a stop.

    Why it helps. Costs no tokens by itself; it turns a silent hang into an error the user can act on.

    Estimate no tokens (reliability)

    Assumptions. streaming requests; the user can always press Stop.

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.

  1. OpenAI-compatible answers cut off at the token limit are shown and saved as complete

    src/services/apis/openai-compatible-core.mjs:148 · LP-GE-12 Read the finish reason before using an answer · severity high · the same problem as finding 3

    What happens. hasFinished (lines 31-33) is true for any finish_reason, and line 148 then calls finish(), which saves the answer to history and marks it done, whether the reason was stop or length. An answer cut off at Max Response Token Length, or an empty one when a reasoning model spent the whole budget thinking, looks like a normal reply. The Claude path already handles this (claude-api.mjs:78-82 raises 'Claude reached the response token limit'). Azure has the same gap (azure-openai-api.mjs:66). This path serves OpenAI, OpenRouter, Gemini, xAI, DeepSeek, Ollama and every other OpenAI-compatible provider.

    The change. Read the reason: when finish_reason is 'length', do not save the record as complete; post the partial text and throw an error like the Claude one ('The answer reached Max Response Token Length (N). Increase it in Advanced settings and try again.'). Treat 'content_filter' the same way with its own message.

    To check. In tests/unit/services/apis/openai-api-compat.test.mjs, a mock stream ending with finish_reason 'length' should produce an error message and no done record; the existing 'stop' tests stay green.

  2. The Ollama keep-alive request after every answer probably evicts the conversation's cached prefix

    src/services/apis/openai-api.mjs:209

    What happens. After each answer, touchOllamaKeepAlive (lines 193-224, called at 336-346) sends a second generation to /api/generate with prompt 't' and num_predict 1. Ollama defaults to one parallel slot (OLLAMA_NUM_PARALLEL, FAQ read 2026-11-27), and its prompt cache keeps only the prefix shared with the newest request, so the next turn of the conversation has to prefill the whole history again. With the default ollamaKeepAliveTime '5m' (src/config/index.mjs:852), which equals Ollama's own default residency, the request also changes nothing.

    The change. Send the documented preload request instead: { model, keep_alive } with no prompt and no options (Ollama FAQ, 'preload a model by sending the Ollama server an empty request'), and skip it entirely when the setting is the default '5m'.

    To check. On a local Ollama with default settings, ask two follow-ups: before the change usage.prompt_tokens on the second follow-up is about the whole history; after it, about the new message only (Ollama reports only evaluated tokens).

  3. Pages and transcripts are cut to about 5,900 tokens for every current model, and less when the output limit is raised

    src/utils/crop-text.mjs:48

    What happens. cropText reads the context size from a 'NNk' in the model's label (lines 41-45). Only GPT-4o 128k and the Kimi API and web modes have one, so every default-enabled model, including 1M-context GPT-6.1 and Gemini 3.x, gets the 8,000-token default minus 100 minus the output limit: about 5,900 tokens. The rest of a page or transcript is decimated, keeping roughly every Nth clause. Raising Max Response Token Length, which is what a cut-off answer needs, makes it worse: at 6,000 or more only 1,900 tokens of the page are sent (line 48). The count uses the GPT-2/3 tokenizer.

    The change. Give each model (or provider) a context-window value and use it instead of parsing the label, keep the output limit out of the input budget for 100k+ models, and when cropping is still needed, cut the middle once with a marker (as #809 proposed) instead of decimating.

    Already reported. open since 2024-10: cropping by decimation produces garbled text; PR #809 (crop the middle) closed unmerged 2025-08; #679 asked for full transcripts and was told to pick a longer-context mode https://github.com/ChatGPTBox-dev/chatGPTBox/issues/800

    To check. Summarise a 2-hour YouTube video on GPT-6.1 Sol: the console's 'input maxLength' log line shows 5900 before the change and the model's window after it.

  4. The model list still offers OpenAI models that have been shut down

    src/config/index.mjs:328 · LP-GE-13 Default to a model the provider still serves · severity low

    What happens. OpenAI's deprecations page (read 2026-11-27) lists gpt-5-chat-latest and gpt-5.1-chat-latest as shut down on 2026-07-23, gpt-5.2-chat-latest and gpt-5.3-chat-latest on 2026-08-10, gpt-3.5-turbo-instruct on 2026-09-28 and gpt-4.1-nano on 2026-10-23; gpt-5 and o3 shut down on 2026-12-11, gpt-4o, gpt-4o-mini, gpt-4.1 and gpt-4.1-mini on 2027-01-14. The modes remain selectable (lines 325-351, 439) and saved selections are preserved, so a user who picked one gets a provider error.

    The change. Remove the shut-down ids or migrate saved selections to OpenAI's named replacements (gpt-5.6-sol for the chat-latest ids, gpt-6-luna for gpt-4o/4.1, gpt-6.1-sol for gpt-5 and o3).

    To check. After the migration, a profile with chatgptApi5_2Latest saved opens with the replacement selected.

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.