Skip to content

[Bug] Long GGUF chat waiting for tool approval blocks queued chats despite free slots #10671

Open

Description

@Imagineer99

Problem

A long GGUF chat waiting for tool approval can leave another chat queued while the monitor reports no active generations and four free serving slots. The approval wait retains the first chat's context-budget commitment, so parking its serving slot alone does not let the queued chat run.

Live reproduction

Reproduced on main 999dd8500f using the real Studio HTTP API and real Qwen3-4B-Instruct-2507 UD-Q4_K_XL inference on an RTX 5070 Ti under WSL/Linux. Runtime: 35,000 context, four effective slots, --kv-unified --cache-ram 0.

  1. Start chat A with synthetic reference history, Python enabled, and permission_mode: ask. Ask it to calculate 17 * 23 with Python.
  2. Wait for the real tool_start event with awaiting_confirmation: true, then leave it unanswered.
  3. In a separate session, ask chat B to reply hello. Both requests enable Python and omit an explicit output limit.
  4. Observe B for five seconds, then resolve A's approval.
A history B completes while approval is pending Monitor
Fresh chat Yes 0 active, 0 queued, 4 free
80,000 characters of reference history Yes 0 active, 0 queued, 4 free
112,000 characters of reference history No 0 active, 1 queued, 4 free

Character counts above are not measured token counts. The longer case reproduced with both Allow and Deny: B completed after the decision and A's turn finished.

Expected behavior / safety constraint

A chat waiting on a human should be suspendable so other chats can use reclaimable context capacity. Any fix must release actual resident KV safely before returning its reservation, and reacquire capacity before the suspended chat resumes. Simply subtracting the parked lease's token commitment would risk overcommitting the shared cache. If capacity cannot be reclaimed, the UI should at least explain the context-budget wait rather than imply free slots guarantee progress.

Original desktop report

Windows 11, desktop v0.1.808-beta, package 2026.9.4, llama.cpp b10840-mix-d5c17a0, RTX 5090, Qwen3.8-27B UD-Q4_K_XL. Multiple chats work around 30k configured context but queue around 35k, including while a tool approval is pending. Reported settings include MTP (2 draft tokens), f16 KV, and four requested parallel slots.

The local reproduction confirms the approval/context-reservation symptom. It does not establish the exact desktop 30k-to-35k threshold, an MTP cause, or an update regression.

Related: #5481 and #5737 concern configurable concurrency; this report concerns context capacity retained during tool approval.

Activity

  1. Imagineer99 commented on Sep 9, 2026

    @Imagineer99
    MemberAuthor

    Additional report from the same Windows setup:

    • With five requested parallel slots, concurrent chats work at exactly 30,000 configured context but queue at 30,001.
    • While six chats were running at 30,000 context, the API information panel did not load until one chat finished.
    • The reported error was: got exception: speculative batch index 16 is not inside the current sub-batch [0, 16).
    • MTP was enabled in the previously supplied settings.

    These are user-reported observations, not results from our local reproduction. The exact one-token threshold and speculative sub-batch failure need separate diagnosis; neither is established as caused by approval parking.

    PR #10673 addresses the independently reproduced context reservation retained during a tool approval wait. Its live A/B proof and 150 passing tests do not establish a fix for the threshold, API panel stall, or speculative-decoding error.

  2. Imagineer99 commented on Sep 9, 2026

    @Imagineer99
    MemberAuthor

    Further isolation from the reporter: changing MTP to Auto still produced the speculative sub-batch errors; turning speculative decoding Off allowed six shorter prompts to finish. Screenshots show /api/chat-runs/producer failures with speculative batch indices 8, 12 and 19 outside [0, 8).

    Source investigation found the exact error string in the local llama.cpp server-context.cpp, in post_decode when a speculative batch index falls outside the current sub-batch. The adjacent source comment explicitly references ggml-org/llama.cpp#24840, which describes speculative index handling when decode batches are split. This is an engine speculative-batching error, not evidence of a six-chat application thread cap.

    Studio Auto mode can still select MTP for supported Qwen models, so MTP -> Auto is not necessarily a test with speculative decoding disabled. We have not yet verified the reporter's exact effective Auto configuration or independently reproduced this speculative failure.

    The API-panel stall and exact 30,000/30,001 threshold remain unexplained. PR #10673 addresses approval/cache-reservation parking only.

  3. Imagineer99 commented on Sep 11, 2026

    @Imagineer99
    MemberAuthor

    Concurrent context overflow reproduced independently

    Pinned baseline: 1ad44677d4. Real Studio HTTP requests and Qwen3-1.7B UD-Q4_K_XL on RTX 5070 Ti under WSL/Linux; 30,000 context, three verified effective slots, unified KV and cache RAM disabled. The reported Nemotron MXFP4_MOE model was not cached, so this is a mechanism reproduction, not an exact-model reproduction.

    The input contains 4,500 space-separated numeric record IDs (1000 through 5499), followed by a request to write integers in order, with a 1,024-token output cap and thinking disabled.

    • Admission prompt estimate: 5,687 tokens.
    • Actual prompt processing, measured by llama-server on the successful single-request control: 22,560 tokens.
    • One request alone completes without an error.
    • Three concurrent copies all receive the SSE error explaining that concurrent chats share one context pool. Engine logs show Context size has been exceeded and unsuccessful KV allocation retries down to batch size 1.
    • HTTP status is 200 because these are already-open SSE streams; the error is in the stream body.

    The numeric input fits individually, but the character-based estimate undercounts it by almost 4x and admits more total context than the shared cache can hold. This is separate from approval parking and is not fixed by PR #10673. Current upstream 27a4ff6a9b still uses the same estimator in _openai_llama_admission_tokens; the complete live test was run on the pinned baseline, not that latest head.

    The original Nemotron 30k report is consistent with this class of failure, but we have not established that its particular prompts hit this undercount. The 220k result would give much more aggregate headroom; it does not prove the admission estimate is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions