-
We're experimenting with the Semantic Kernel Agent Framework (v1.63.0) in a .NET 8 Web API application and encountering a service selection issue when multiple Azure OpenAI chat completion services are registered in the dependency Setup Service Registration in Program.cs:
Agent Creation:
Problem When invoking the agent, we consistently get: What We've Tried
Questions
Looking at the ChatCompletionAgent source code, it uses GetChatCompletionService(kernel, arguments) which relies on the kernel's service selector, but it seems to fail despite our services being registered correctly. Environment
Any guidance would be greatly appreciated! We're excited about the agent framework but stuck on this service selection issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Update: Keyed Kernels Workaround - Works but Need Design Feedback The workaround solution works! Here's what we implemented: What We Did Instead of trying to select services within a single kernel, we created multiple dedicated kernels using keyed services: // Program.cs - Register dedicated kernels for each service
Results
Design Concerns & Questions While this approach works, I'm wondering about the design implications:
Alternative Patterns Considered
Would love to hear from the SK team: Is this keyed kernel approach considered a best practice, or should we expect better service selection support in future versions? Thanks for any guidance! |
Beta Was this translation helpful? Give feedback.
I'd say you're on the right path. In the solution I work on, we deal with one Semantic Kernel instance per "Document Process" - or document type - each document type can have (different) assigned plugins and the embedding and chat models are user-selectable in the admin UI per document type.
We did previously register every SK instance in the DI container individually, but we no longer do this, as it requires a restart of the affected service each time a document type is added or its associated models are changed. Today, we use the factory pattern, where a SemanticKernelFactory (custom type) is registered in the kernel as a singleton. You can have a collection in the factory (for instance…