Repository navigation
Handle multiple tool calls in ChatSession - #162
Merged
Merged
Conversation
The generation loop was breaking on the first tool call, canceling the stream, and losing the rest. Now it drains the stream, collects all tool calls, dispatches them, and restarts with all tool results. Skips dispatch if the consumer has canceled (Task.isCancelled). No change to the streamDetails path. Fixes ml-explore#134.
davidkoski
approved these changes
Mar 27, 2026
davidkoski
left a comment
Member
There was a problem hiding this comment.
Nice and simple, thank you!
TheTom
referenced
this pull request
in TheTom/mlx-swift-lm
Apr 5, 2026
The generation loop was breaking on the first tool call, canceling the stream, and losing the rest. Now it drains the stream, collects all tool calls, dispatches them, and restarts with all tool results. Skips dispatch if the consumer has canceled (Task.isCancelled). No change to the streamDetails path. Fixes ekryski#134.
davidtai
added a commit
to davidtai/mlx-swift-lm
that referenced
this pull request
Oct 6, 2026
* ci: build the fork and run its Metal test suites Add the Fork Tests workflow. It builds the package on a macos-26 runner, builds the full MLX Metal library with cmake, copies it next to the test binaries, and runs six CBv2 paged suites one step each. A suite step fails when the suite executes zero tests or skips a test. Port the scripts from d-inference and add them to fork.yaml. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: remove the empty GPU listing from Fork Tests system_profiler SPDisplaysDataType prints nothing on the hosted macos-26 VM. The CPU, memory and disk lines stay. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: test the nested-suite tripwire Add scripts/test-run-nested-suite.sh. It runs run-nested-suite.sh with a fake swift command and checks the exit code for 12 outputs: passing XCTest and Swift Testing runs, zero executed tests, no output, an XCTest skip, Swift Testing skips with the Swift 6.1 symbol, the Swift 6.3 symbol, no symbol and no reason, a suite skip, test output that contains the word "skipped", and a failing swift test. It also checks the arguments that swift gets. Run it as the first step of Fork Tests and list it in fork.yaml. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: select the newest release of Xcode 26 in Fork Tests Pick the newest Xcode_26.x app whose name is only a version number. Beta and release candidate apps are left out, so a new beta on the runner image cannot change CI without a pull request. The step still fails when the selected Swift is older than 6.3. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: correct the Metal library notes in build-metallib.sh swift build makes no Metal library. The pinned mlx-swift excludes the MLX kernel sources and nojit_kernels.cpp from Cmlx, so SwiftPM builds MLX in JIT mode, and every MLX operation traps without a staged mlx.metallib. The partial 459-symbol library comes from xcodebuild, which this workflow does not use. State that the 10,000-symbol floor rejects a JIT-mode or incomplete cmake build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci: key the SwiftPM cache on the commit and clean it before saving End the cache key with the commit SHA, as d-inference does, so each push to main saves a new entry. The prefix restore key still restores the newest entry for the same Xcode. Before the save, delete the staged mlx.metallib copies and the coverage data, so the cache keeps only SwiftPM output. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci: fix wording in the Fork Tests files - run-nested-suite.sh: the suites need no model weights, but one test needs DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST=1, which the caller sets. - fork-tests.yml: runs on main are not cancelled once they start. - Say "self-contained" instead of "hermetic" in the workflow and in fork.yaml. - fork.yaml: write the Fork Tests paragraph as one sentence per line, so later pull requests can add a sentence without touching the same lines. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci: test more skip forms and the paged kernel runner - Add a case for the plural XCTest skip line, "with 2 tests skipped". - Remove the third skip pattern, "skipped N test", from run-nested-suite.sh. No current tool prints it: Swift Testing prints one "skipped" line for each test and no skip count, XCTest prints "with N test(s) skipped", and SwiftPM prints neither. - Test run-paged-kernel-tests.sh with a fake swift that answers per filter: both processes pass; the first fails and the second still runs; the second fails; the first executes zero tests. Check that the first process runs without DARKBLOOM_EXCLUSIVE_NATIVE_GPU_TEST and the second with it set to 1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Gajesh Naik <26431906+Gajesh2007@users.noreply.github.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.
Fixes #134.
The generation loop was breaking on the first tool call, canceling the stream, and losing the rest. Now it drains the stream, collects all tool calls, dispatches them, and restarts with all tool results. Works for both mid-stream (JSON/XML tagged) and EOS-emitted (Mistral) tool calls.
Skips dispatch if the consumer has canceled. No change to the
streamDetailspath — callers withouttoolDispatchstill get tool call items directly.