Resolve tool calls through one shared implementation - #4
Merged
Conversation
This was referenced Aug 3, 2026
ActuallyTaylor
force-pushed
the
feature/central-tool-resolution
branch
from
August 3, 2026 19:35
3f72c2c to
6925e25
Compare
Six providers each carried their own copy of the same delegate/decision/execute state machine, along with their own `ToolInvocationResult` and `ToolResolutionOutcome` differing only in name. Every copy had to be kept in step by hand, and they had already drifted in small ways, such as whether an empty batch returns early. `resolveToolCalls` now lives in `ToolResolution.swift` beside the `ToolExecutionDelegate` protocol it implements, and takes the provider-neutral `[Transcript.ToolCall]` that each provider was already building. Providers keep only the part that is genuinely theirs — mapping their native call shape onto `Transcript.ToolCall` — and hand off. No behavior change: the shared implementation is the one the Anthropic path already used, and its live tool tests still pass against the API.
ActuallyTaylor
force-pushed
the
feature/central-tool-resolution
branch
from
August 3, 2026 19:39
6925e25 to
28e5c10
Compare
ActuallyTaylor
commented
Aug 3, 2026
ActuallyTaylor
left a comment
Collaborator
Author
There was a problem hiding this comment.
Looks good, the same tool call was repeated across the files. This cleans that up a lot
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.
Six providers each carried their own copy of the same delegate/decision/execute state machine for tool calls, along with their own
ToolInvocationResultandToolResolutionOutcomethat differed only in name. Every copy had to be kept in step by hand, and they had already drifted — for example in whether an empty batch returns early.resolveToolCallsnow lives inToolResolution.swift, beside theToolExecutionDelegateprotocol it implements, and takes the provider-neutral[Transcript.ToolCall]that each provider was already constructing. Providers keep only the part that is genuinely theirs — mapping their native call shape ontoTranscript.ToolCall— and hand off.No behavior change. The shared implementation is the one the Anthropic path already used. Its live tool tests still pass against the API.
-588 / +161lines across Anthropic, Gemini, Ollama, OpenAI, OpenResponses and MLX.Important
Merge this first. The eight provider PRs that add streaming tool calling are all based on this branch and use the shared function. Merging them first would reintroduce the duplicates.
🤖 Generated with Claude Code