fix: selective de-streaming, threaded server, and config-driven GET paths#4
Open
Nannerz wants to merge 1 commit intocrashr:mainfrom
Open
fix: selective de-streaming, threaded server, and config-driven GET paths#4Nannerz wants to merge 1 commit intocrashr:mainfrom
Nannerz wants to merge 1 commit intocrashr:mainfrom
Conversation
…ig-driven GET paths - Only force stream:false when tools/tool_choice/response_format are present (avoids client timeouts on normal streaming completions) - Use ThreadingMixIn so concurrent requests don't block each other (fixes deadlock when long-lived SSE connections are active) - Stream reasoning_content (thinking) in chunks before content/tool_calls (previously silently dropped by _simulate_streaming) - Read allowed_get_paths from config instead of hardcoding /v1/models - Catch BrokenPipeError on client disconnect instead of full traceback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Issues fixed with Opus as I found them. I use concurrent sessions so needed to add support for that. Added selective de-streaming so streaming still works for things outside of tool calls. "allowed_get_paths" wasn't getting used so fixed that. Also fixed some traceback spam. Below is an LLM generated summary.
Summary
Five improvements discovered while running llama-stream in production as a reverse proxy in front of llama-swap:
stream: falsewhen the request containstools,tool_choice, orresponse_format(the fields that trigger thellama_grammar_init_implgrammar bug in llama-server). Normal chat completions now pass through with native streaming, preventing client timeouts on long responses.http.server.HTTPServerwith aThreadingMixInsubclass so concurrent requests don't block each other. The original single-threaded server deadlocks when a long-lived connection (like an SSE endpoint) is active._simulate_streamingnow includesreasoning_content(thinking/reasoning) from the backend response, streamed in chunks before content/tool_calls. Previously this field was silently dropped.do_GETnow reads from theallowed_get_pathsconfig instead of hardcoding/v1/models.Test plan
curl /v1/modelsreturns instantly (was previously blocked by concurrent SSE connections)