-
Couldn't load subscription status.
- Fork 840
Tool reduction #6781
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
Tool reduction #6781
Conversation
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/ToolReducingChatClient.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/ToolReducingChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs
Show resolved
Hide resolved
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 PR introduces a tool reduction feature set for managing large tool catalogs in AI chat applications. The feature allows for automatically selecting a subset of tools per request using configurable strategies.
Key changes:
- New abstractions for tool reduction strategies with an embedding-based implementation
- Middleware that automatically applies tool reduction to chat requests
- Comprehensive test coverage including integration tests across different scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.AI.Abstractions/ToolReduction/IToolReductionStrategy.cs | Defines the core abstraction interface for tool reduction strategies |
| src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs | Implements embedding-based tool selection using similarity scoring |
| src/Libraries/Microsoft.Extensions.AI/ToolReduction/ToolReducingChatClient.cs | Middleware client that applies tool reduction before delegating to inner client |
| src/Libraries/Microsoft.Extensions.AI/ToolReduction/ChatClientBuilderToolReductionExtensions.cs | Extension methods for integrating tool reduction into chat client pipelines |
| test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ToolReductionTests.cs | Comprehensive unit and integration tests for tool reduction functionality |
| test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs | Integration tests demonstrating real-world tool reduction scenarios |
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIChatClientIntegrationTests.cs | Adds embedding generator support for OpenAI integration tests |
| src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj | Adds System.Numerics.Tensors dependency for embedding similarity calculations |
| eng/packages/General.props | Moves System.Numerics.Tensors to general packages from test-only |
| eng/packages/TestOnly.props | Removes System.Numerics.Tensors from test-only packages |
Comments suppressed due to low confidence (2)
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs:1
- This method exceeds 120 characters per line. Consider breaking the parameter list across multiple lines for better readability.
// Licensed to the .NET Foundation under one or more agreements.
src/Libraries/Microsoft.Extensions.AI/ToolReduction/EmbeddingToolReductionStrategy.cs:1
- This method exceeds 120 characters per line. Consider breaking the parameter list across multiple lines for better readability.
// Licensed to the .NET Foundation under one or more agreements.
test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs
Outdated
Show resolved
Hide resolved
…lientIntegrationTests.cs Co-authored-by: Copilot <[email protected]>
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.
Looks good to get out there and get feedback.
I think this will still only expose a subset of the tools to the model, with no way for the model to page in the rest - but I suppose that's by design for this implementation.
Summary
This draft introduces the tool reduction feature set:
IToolReductionStrategy) for selecting a subset of tools per request.ToolReducingChatClient) that applies a configured strategy automatically.EmbeddingToolReductionStrategy) as a first strategy.All components are marked experimental and may evolve. Additional strategies can be added in follow-up work.
Next Steps
Feedback welcome before expanding scope.
Fixes #6670
Microsoft Reviewers: Open in CodeFlow