microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
20.45k stars 2.97k forks source link

.Net: The Kernel could be part of the constructor to enable DI scenarios for agents #6038

Open matthewbolanos opened 2 months ago

matthewbolanos commented 2 months ago

Note: Property injection (as opposed to constructor injection) might be an option that helps minimize bubbling constructor arguments.

stephentoub commented 2 months ago

Agents are constructed to wrap Kernel instances rather than the Kernel being passed to operations on agents? Doesn't that go against the scheme that was set up for services?

matthewbolanos commented 2 months ago

We ended up choosing to go that route (wrap a kernel object instead of passing it during every operation) since this mimics the behavior we've seen from other agent frameworks. They create their agent once with the required AI service and necessary plugins. In our framework, that's equivalent to creating a kernel and binding it to an agent.

That being said... we also see patterns like the Assistants API that allows for both, i.e., defining the base model/plugins for an agent and also allowing overrides for individual invocations. I believe the latter will need to be added as an enhancement to our framework.

matthewbolanos commented 2 months ago

Looks like I created that issue here: https://github.com/microsoft/semantic-kernel/issues/6037