Repository navigation
feat: retry once on silent fusion-mlx streams - #334
Merged
Merged
Conversation
A local-engine stream that completes with no text and no tool_use (empty or thinking-only) is a degraded-engine slip, not a valid assistant turn. The agent loop previously continued to the next turn, burning one turn of the budget on nothing. Add withSilentStreamRetry: buffer leading non-content events (message_start, thinking deltas), flush them on first real content, and if the stream ends silently, discard the buffer and re-issue the request once. Thinking-only streams count as silent, matching Claude Code v2.1.331's silent-reply retry; adapted for the local engine where no non-streaming fallback endpoint exists. Wired at both fusion-mlx entry points (streamFusionMlx generator and the createFusionMlxFetch interceptor used by the agent loop). Skipped on the stream-resume path: a re-issued request gets a new stream id and would invalidate the cursor/state side-channels. Tests: 4 new cases (pass-through, silent retry, thinking-only retry, give-up after second silent attempt). Full suite 1841 pass / 0 fail. Co-Authored-By: Claude Code <[email protected]>
This was referenced Nov 25, 2026
Merged
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
A local-engine stream that completes with no text and no tool_use (empty or thinking-only) is a degraded-engine slip, not a valid assistant turn. The agent loop previously continued to the next turn, burning one turn of the turn budget on nothing — expensive for small models with a 20-turn cap.
Change
withSilentStreamRetryinfusion-mlx-stream.ts: buffer leading non-content events (message_start, thinking deltas), flush them on first real content (zero added latency once content flows), and if the stream ends silently, discard the buffer and re-issue the request once. Thinking-only streams count as silent, mirroring Claude Code v2.1.331's silent-reply retry; adapted for the local engine where no non-streaming fallback endpoint exists.streamFusionMlxgenerator and thecreateFusionMlxFetchinterceptor (the path the agent loop actually uses).Tests
4 new cases: content pass-through (single attempt), silent retry, thinking-only retry, give-up after second silent attempt. Full suite 1841 pass / 0 fail. Build green, doc validator 0 ERROR.
🤖 Generated with Claude Code