fix: continue session loop when response is truncated by length (problem with local, smaller LLMs) - #39397
Open
erkkiat wants to merge 2 commits into
Open
fix: continue session loop when response is truncated by length (problem with local, smaller LLMs)#39397erkkiat wants to merge 2 commits into
erkkiat wants to merge 2 commits into
Conversation
When a model's finish reason is "length" (hit the output token cap mid-turn) and no tool call was started, the session loop currently ends and goes idle, requiring the user to manually type "continue". This treats "length" like "tool-calls" so the loop keeps going automatically instead.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PR FoundPR #26167 - This appears to be related as it also handles stream truncations in sessions, though the approach differs (retrying vs continuing). This PR may be worth reviewing to understand any overlapping concerns or previous solutions. The current PR (#39397) is specifically addressing truncations caused by output token limits with local models, while #26167 appears to focus on empty stream truncations. |
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.
Issue for this PR
Closes #17471
Type of change
What does this PR do?
When using local models such as qwen3.6:35b, the context window limitations will break the flow on a regular basis. When a model's finish reason is "length" (hit the output token cap mid-turn) and no tool call was started, the session loop currently ends and goes idle, requiring the user to manually type "continue". This treats "length" like "tool-calls" so the loop keeps going automatically instead. The fix suggested in #17471 can work, but here is an alternate, perhaps cleaner solution.
How did you verify your code works?
I have used a version with this fix for a couple of weeks, and it works continuously without requiring manual intervention. I want to share a working solution.
Screenshots / recordings
No UI changes.
Checklist