Add extensible chat client routing - #7662
Open
joshuajyue wants to merge 16 commits into
Open
Conversation
Introduce one-shot and failover routing primitives, ordered and semantic routing implementations, lifecycle reporting, streaming safeguards, and focused routing tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Treat provider-thrown cancellation as terminal, materialize semantic routing messages before inspection, and enforce non-null selection consistently for streaming. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
Capture Current access failures before committing output so pre-output failover and attempt reporting remain accurate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
Apply ConfigureAwait(false) consistently across selection, invocation, streaming, disposal, and routing update awaits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
PranavSenthilnathan
requested review from
PranavSenthilnathan,
jeffhandley and
jozkee
July 28, 2026 22:09
joshuajyue
commented
Jul 29, 2026
Member
Author
There was a problem hiding this comment.
Addressed in commit 0abbfd1, along with some cancellation races
joshuajyue
force-pushed
the
routing-behaviors
branch
from
July 29, 2026 20:44
a19b74b to
0abbfd1
Compare
Clarify RoutingContext input semantics, add optional message buffering, centralize validation, simplify timing and disposal, and separate caller cancellation from provider failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
jozkee
reviewed
Jul 29, 2026
jozkee
reviewed
Jul 30, 2026
Clone request options for selector shaping and restrict routing updates to concrete client attempts, leaving selection-failure cleanup to selectors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
jozkee
reviewed
Jul 30, 2026
Follow MEAI's repeatable-enumerable convention and propagate selector failures without cancellation rewriting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
jozkee
reviewed
Jul 30, 2026
Use ConcurrentDictionary atomic operations instead of explicit lock blocks while preserving the narrow request-state lifetime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
joshuajyue
force-pushed
the
routing-behaviors
branch
from
July 31, 2026 01:12
896e51d to
a576773
Compare
Keep client selection simple while preventing selector and failed-client option mutations from affecting downstream attempts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
Document client-reference identity and keep semantic scoring parameters together in the constructor signature. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
jozkee
reviewed
Jul 31, 2026
Align routing code with MEAI formatting and documentation conventions, simplify disposal, and split routing tests by component and assembly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
Member
Author
|
Thank you David for the feedback, addressed in 8b79ae4 |
jozkee
approved these changes
Jul 31, 2026
Consolidate shared streaming and non-streaming cases, reuse routing test helpers, and simplify semantic router disposal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74d04840-2379-4615-93f7-84f2299ada74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #7647
Summary
Adds experimental chat-routing primitives for selecting configured
IChatClientinstances without imposing a particular routing policy.RoutingChatClientsupports one-shot client selection.FailoverChatClientretries uncanceled failures that occur before output is exposed.OrderedFailoverChatClientprovides ordered fallback.SemanticRoutingChatClientselects clients using cached profile embeddings.RoutingContextexposes mutable request messages and options.FailoverChatClientAttemptreports invocation outcome, duration, time to first update, completion, and output commitment.API shape
Routing policies have two seams:
SelectClientAsyncruns before every invocation.OnRoutingUpdateAsyncreports each attempt so policy state can influence the next selection.isTerminalmeans the base will not select another client after the callback completes. A null attempt represents selection terminating before a client was invoked.Failover behavior
Semantic routing
SemanticRoutingChatClient:topK: 1.leaveOpen.Tests
Coverage includes selection failures, retries, cancellation, attempt limits, streaming commitment, early disposal, enumerator failures, concurrent requests, state cleanup, semantic thresholds, top-K aggregation, caching, and ownership.
net10.0net472test project builds successfullyMicrosoft Reviewers: Open in CodeFlow