-
Notifications
You must be signed in to change notification settings - Fork 799
.NET: MapAGUI supports per-request agent selection #2343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for per-request agent selection to the MapAGUI endpoint routing functionality. Previously, agents were statically bound to endpoints; now, agents can be dynamically selected based on route parameters or other HttpContext data using a selector function.
Key changes:
- Added a new
MapAGUIoverload that accepts aFunc<HttpContext, ValueTask<AIAgent>>selector - Refactored the existing
MapAGUImethod to delegate to the new overload - Added sample code demonstrating dynamic agent selection using route parameters
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs | Added new MapAGUI overload with agent selector function and refactored existing overload to use it |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs | Added basic test to verify endpoint mapping with agent selector function |
| dotnet/samples/AGUIClientServer/AGUIServer/Program.cs | Added example demonstrating per-request agent selection based on route parameter |
| dotnet/samples/AGUIClientServer/AGUIDojoServer/Program.cs | Added example demonstrating per-request agent selection with multiple agent types based on route parameter |
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs
Show resolved
Hide resolved
b2e6f0b to
3c8403e
Compare
3c8403e to
7ec1c13
Compare
|
@microsoft-github-policy-service agree |
|
Nice, need this as well! |
Motivation and Context
The current AGUI agent mapping binds one agent to an endpoint route. There is currently no way to bind an agent dynamically to an endpoint route with route parameters.
With this change we can select an
AIAgentper-request based on route parameters or anything fromHttpContext.This also addresses #2179.
Description
Additionally to providing an
AIAgentinstance directly during route building, we can now also provide aFunc<HttpContext, AIAgent>to determine theAIAgentper-request on-demand based on route parameters or anything fromHttpContext.Contribution Checklist