Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using TelegramSearchBot.LLMAgent;
using TelegramSearchBot.LLMAgent.Service;
using TelegramSearchBot.Service.AI.LLM;
using Xunit;

Expand All @@ -13,6 +14,17 @@ public void BuildServices_RegistersResponsesApiExecutor() {
Assert.NotNull(provider.GetService<ResponsesModelApi>());
}

// Regression: LlmServiceProxy ctor resolves LlmChatRunner; a missing registration crashed every agent task.
[Fact]
public void BuildServices_RegistersAgentTaskExecutor() {
using var provider = BuildAgentServices();
using var scope = provider.CreateScope();

var executor = scope.ServiceProvider.GetRequiredService<IAgentTaskExecutor>();

Assert.NotNull(executor);
}

private static ServiceProvider BuildAgentServices() {
var method = typeof(LLMAgentProgram).GetMethod("BuildServices", BindingFlags.NonPublic | BindingFlags.Static);
Assert.NotNull(method);
Expand Down
3 changes: 3 additions & 0 deletions TelegramSearchBot.LLMAgent/LLMAgentProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ private static ServiceProvider BuildServices(int port) {
services.AddScoped<OllamaModelApi>();
services.AddScoped<GeminiModelApi>();
services.AddScoped<AnthropicModelApi>();
// LlmServiceProxy resolves LlmChatRunner, which needs the registry (same lifetimes as the main process DI scan).
services.AddSingleton<LlmProviderRegistry>();
services.AddSingleton<LlmChatRunner>();
services.AddSingleton<Service.ToolExecutor>();
services.AddScoped<Service.AgentToolService>();
services.AddScoped<IFileToolService, FileToolService>();
Expand Down
Loading