Skip to content

Add tool execution delegate#109

Merged
mattt merged 9 commits intomainfrom
mattt/tool-callback
Feb 5, 2026
Merged

Add tool execution delegate#109
mattt merged 9 commits intomainfrom
mattt/tool-callback

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Feb 5, 2026

Alternative to #108

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a ToolExecutionDelegate protocol that allows observing and controlling tool execution in language model sessions. It provides an alternative to PR #107's provider-specific approach by implementing a universal delegate pattern that works across all model providers.

Changes:

  • Adds ToolExecutionDelegate protocol with methods to observe and control tool execution lifecycle
  • Implements ToolExecutionDecision enum supporting .execute, .stop, and .provideOutput decisions
  • Integrates delegate hooks into all model implementations (OpenAI, Ollama, MLX, Gemini, Anthropic)

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Sources/AnyLanguageModel/LanguageModelSession.swift Defines the ToolExecutionDelegate protocol, ToolExecutionDecision enum, and adds toolExecutionDelegate property to LanguageModelSession
Sources/AnyLanguageModel/Models/OpenAILanguageModel.swift Integrates delegate hooks into tool resolution logic for both streaming and non-streaming responses
Sources/AnyLanguageModel/Models/OllamaLanguageModel.swift Integrates delegate hooks into tool resolution logic
Sources/AnyLanguageModel/Models/MLXLanguageModel.swift Integrates delegate hooks into tool resolution logic
Sources/AnyLanguageModel/Models/GeminiLanguageModel.swift Integrates delegate hooks into tool resolution logic
Sources/AnyLanguageModel/Models/AnthropicLanguageModel.swift Integrates delegate hooks into tool resolution logic
Tests/AnyLanguageModelTests/ToolExecutionDelegateTests.swift Adds comprehensive tests for all three decision types (.stop, .provideOutput, .execute)
README.md Documents the new delegate pattern with a practical example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit 2ba70aa into main Feb 5, 2026
3 checks passed
@mattt mattt deleted the mattt/tool-callback branch February 5, 2026 12:56
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.

1 participant