Repository navigation
Stream a rejected generation's error instead of nothing - #279
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When llama.cpp rejects a generation (seen:
Requested tokens (12337) exceed context window of 8192, a tool conversation past an 8k window),LlamaCpp::streamonly loggedGeneration failedand returned an empty stream. The chat router then saw an empty reply, no calls and no failure, and ended the turn with a barestop. Docent showed0 tokens · 0sand nothing else; the only trace was inserver.log.Change
LlamaCppStreamcarries the failure and yields it as its single chunk, asError 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 astreaming/errorstatus and the error as the reply's text. Applies to both the tools path and the plain path ofstream.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
explorereads to the window and asks again after an empty reply. Fitting tool rounds to the model's actualn_ctxis still open.🤖 Generated with Claude Code