-
Notifications
You must be signed in to change notification settings - Fork 55
Add tool execution delegate #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
ToolExecutionDelegateprotocol with methods to observe and control tool execution lifecycle - Implements
ToolExecutionDecisionenum supporting.execute,.stop, and.provideOutputdecisions - 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
Alternative to #108