Repository navigation
fix(mlx-stream): recover degraded call_<hex> tool-call emissions - #321
Merged
Merged
Conversation
Local engine (fusion-mlx #1694) occasionally emits a tool call as plain
text `call_<hex>{"arg": ...}` with no tool name when a concurrent decode
row is realigned. The call never executed and the agent task timed out.
Add a last-priority extraction pattern: balanced-JSON parse after the
call id, tool name inferred from the argument signature (Edit/Write
before Read since both carry file_path). Slips matching no known
signature stay as visible text instead of being guessed. A fresh
toolu_ id is generated so it cannot collide with a prior structured
call that shares the slip id.
Covered by both streaming (text buffer) and non-streaming response
paths, which share extractToolCallsFromText. Real slip texts from bench
transcripts T14/T17 (run 2026-11-23T09-18-37-611Z) are used as tests.
Co-Authored-By: Claude Code <[email protected]>
This was referenced Nov 24, 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
Engine-side degradation (dahai80/fusion-mlx#1694): under concurrent decoding load, a request occasionally emits its tool call as plain text in the shape
No tool name key, so the existing text-recovery patterns (all require a name) cannot match. The call never executes and the bench task typically times out. Observed in 2 of 4 full 27B bench runs (T14 + T17 slips in run
2026-11-23T09-18-37-611Z).Fix
Add a last-priority extraction pattern in
extractToolCallsFromText:\bcall_[0-9a-f]{6,}{and extract the balanced JSON after it (handles{ }inside string args, e.g. heredoc commands).Edit(old/new_string) →Write(content) →Bash(command) →WebSearch/WebFetch/Grep→Read(file_path).toolu_id generated, so no collision with a prior structured call that shares the slip id (T14's slip id was already consumed by a real executed call).Tests
Three new cases in
tests/services/api/fusion-mlx-stream.test.ts, two using the verbatim slip texts from the T14/T17 bench transcripts:call_8a3b4f2e{"file_path": ...}bun test: 1824 pass, 0 fail.typecheck,lint,bun run buildclean.🤖 Generated with Claude Code