Let tools tailor what they offer to each request

This commit is contained in:
Thorsten Sommer committed 2026-09-24 14:51:27 +02:00
1 parent 38d4520e80
commit 51e7f621bb
12 files changed
+452 -126

No files matched your search

@@ -86,8 +86,13 @@ public sealed class ProviderAnthropic() : BaseProvider(LLMProviders.ANTHROPIC, n
var providerSettings = this.CreateSettingsProvider(chatModel);
var runnableTools = toolRegistry is null
? []
: await toolRegistry.GetRunnableToolsAsync(providerSettings, chatThread.RuntimeComponent, chatThread.RuntimeSelectedToolIds,
this.Provider.GetConfidence(settingsManager).Level, chatThread.MayRunTools(settingsManager));
: await toolRegistry.GetRunnableToolsAsync(new ToolResolutionContext
{
Provider = providerSettings,
Component = chatThread.RuntimeComponent,
ProviderConfidence = this.Provider.GetConfidence(settingsManager).Level,
ChatThread = chatThread,
}, chatThread.RuntimeSelectedToolIds, chatThread.MayRunTools(settingsManager), token);
var systemPrompt = chatThread.PrepareSystemPrompt(settingsManager, runnableTools.Select(x => x.Definition));
if (toolExecutor is not null && runnableTools.Count > 0)
@@ -1314,11 +1314,16 @@ public abstract class BaseProvider : IProvider, ISecretId
{
var providerSettings = this.CreateSettingsProvider(chatModel);
var runnableTools = await toolRegistry.GetRunnableToolsAsync(
providerSettings,
chatThread.RuntimeComponent,
new ToolResolutionContext
{
Provider = providerSettings,
Component = chatThread.RuntimeComponent,
ProviderConfidence = this.Provider.GetConfidence(settingsManager).Level,
ChatThread = chatThread,
},
chatThread.RuntimeSelectedToolIds,
this.Provider.GetConfidence(settingsManager).Level,
chatThread.MayRunTools(settingsManager));
chatThread.MayRunTools(settingsManager),
token);
systemPrompt = new TextMessage
{
@@ -191,11 +191,16 @@ public sealed class ProviderOpenAI() : BaseProvider(LLMProviders.OPEN_AI, new Ur
IReadOnlyList<(ToolDefinition Definition, IToolImplementation Implementation)> runnableTools = toolRegistry is null
? []
: await toolRegistry.GetRunnableToolsAsync(
providerSettings,
chatThread.RuntimeComponent,
new ToolResolutionContext
{
Provider = providerSettings,
Component = chatThread.RuntimeComponent,
ProviderConfidence = providerConfidence,
ChatThread = chatThread,
},
chatThread.RuntimeSelectedToolIds,
providerConfidence,
chatThread.MayRunTools(settingsManager));
chatThread.MayRunTools(settingsManager),
token);
var toolAwareDefinitions = toolExecutor is null
? Enumerable.Empty<ToolDefinition>()