Skip to content

Resolve tool calls through one shared implementation - #4

Merged
ActuallyTaylor merged 1 commit into
mainfrom
feature/central-tool-resolution
Aug 3, 2026
Merged

Resolve tool calls through one shared implementation#4
ActuallyTaylor merged 1 commit into
mainfrom
feature/central-tool-resolution

Conversation

@ActuallyTaylor

Copy link
Copy Markdown
Collaborator

Six providers each carried their own copy of the same delegate/decision/execute state machine for tool calls, along with their own ToolInvocationResult and ToolResolutionOutcome that 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.

resolveToolCalls now lives in ToolResolution.swift, beside the ToolExecutionDelegate protocol 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 onto Transcript.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 / +161 lines 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

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
ActuallyTaylor force-pushed the feature/central-tool-resolution branch from 6925e25 to 28e5c10 Compare August 3, 2026 19:39

@ActuallyTaylor ActuallyTaylor left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the same tool call was repeated across the files. This cleans that up a lot

@ActuallyTaylor
ActuallyTaylor merged commit 956d422 into main Aug 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants