Skip to content

Stream a rejected generation's error instead of nothing - #279

Merged
mehfuzh merged 1 commit into
mainfrom
fix/report-generation-failure-in-stream
Nov 30, 2026
Merged

mehfuzh merged 1 commit into
mainfrom
fix/report-generation-failure-in-stream

Conversation

@mehfuzh

@mehfuzh mehfuzh commented Nov 30, 2026

Copy link
Copy Markdown
Member

Problem

When llama.cpp rejects a generation (seen: Requested tokens (12337) exceed context window of 8192, a tool conversation past an 8k window), LlamaCpp::stream only logged Generation failed and returned an empty stream. The chat router then saw an empty reply, no calls and no failure, and ended the turn with a bare stop. Docent showed 0 tokens · 0s and nothing else; the only trace was in server.log.

Change

LlamaCppStream carries the failure and yields it as its single chunk, as Error generating response: <error>, the form the router already treats as a failure (chat.rs, "A local model's failure comes back as answer text"): it logs it, sends a streaming/error status and the error as the reply's text. Applies to both the tools path and the plain path of stream.

Tests

New tests/unit/test_llama_cpp_stream_failure.rs: a fake model that rejects every request; a plain prompt and a tool conversation each stream the error. cargo test: all pass.

Related

docent: smartloop-labs/docent#106 sizes explore reads to the window and asks again after an empty reply. Fitting tool rounds to the model's actual n_ctx is still open.

🤖 Generated with Claude Code

When llama.cpp rejected a request (a prompt past the context window,
say), the stream only logged it and yielded nothing. The chat router
saw an empty reply and ended the turn on a bare stop, so the client got
no answer and no reason. The stream now yields the error as its one
chunk, in the "Error generating response: ..." form the router already
reads as a failure.
@mehfuzh
mehfuzh merged commit 236dfdc into main Nov 30, 2026
5 checks passed
@mehfuzh
mehfuzh deleted the fix/report-generation-failure-in-stream branch November 30, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant