Skip to content

Fix dependency injection error when starting AgentAlpha#76

Merged
johnkord merged 2 commits intomainfrom
copilot/fix-75
Jun 26, 2025
Merged

Fix dependency injection error when starting AgentAlpha#76
johnkord merged 2 commits intomainfrom
copilot/fix-75

Conversation

Copy link
Copy Markdown

Copilot AI commented Jun 26, 2025

Fixes a dependency injection error that prevented AgentAlpha from starting. The error occurred when trying to resolve IOpenAIResponsesService for the ToolSelector service:

❌ Agent failed with error: Unable to resolve service for type 'OpenAIIntegration.IOpenAIResponsesService' while attempting to activate 'AgentAlpha.Services.ToolSelector'.

Root Cause

The ToolSelector service requires IOpenAIResponsesService in its constructor, but the DI container only had OpenAIResponsesService registered as a concrete type, not as the interface.

Solution

Changed the service registration in ServiceCollectionExtensions.cs from:

services.AddSingleton(provider => new OpenAIResponsesService(configuration.OpenAiApiKey));

to:

services.AddSingleton<IOpenAIResponsesService>(provider => new OpenAIResponsesService(configuration.OpenAiApiKey));

This registers the service as the interface type, allowing the DI container to resolve it properly for dependent services.

Verification

  • ✅ AgentAlpha now starts successfully without dependency injection errors
  • ✅ All existing tests continue to pass (141 passed, 2 skipped)
  • ✅ The fix is minimal and surgical - only one line changed

Fixes #75.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.openai.com
    • Triggering command: /home/REDACTED/work/agents/agents/src/Agent/AgentAlpha/bin/Debug/net8.0/AgentAlpha test task (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: johnkord <16021727+johnkord@users.noreply.github.com>
Copilot AI changed the title [WIP] Issue when starting AgentAlpha Fix dependency injection error when starting AgentAlpha Jun 26, 2025
Copilot AI requested a review from johnkord June 26, 2025 03:00
@johnkord johnkord marked this pull request as ready for review June 26, 2025 04:45
@johnkord johnkord merged commit 7d0a6ab into main Jun 26, 2025
@johnkord johnkord deleted the copilot/fix-75 branch June 26, 2025 04:45
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.

Issue when starting AgentAlpha

2 participants