Repository navigation
fix(ai): provider is the primary key in the model picker sort - #2369
Conversation
AgentPickerProjection.ProjectModels sorted by Order first and Provider second, so a per-model Order pin (ModelOrdering.Defaults, promoting one model to be the deployment default) could lift that model out of its provider's contiguous run — the dropdown then rendered the same provider under two separate headers with the pinned model stranded between them. Provider is now the primary key, mirroring ProjectAgents' GroupName- first sort, so every provider's models are contiguous by construction. Order becomes the tie-break INSIDE the group — a pin still promotes its model to the top of its own provider's block, which is what the pin is for. The router (Auto) is pinned ahead of every provider via an explicit IsRouter-first key, preserving its "sorts ahead of everything" intent (RouterOrder = -10) regardless of where "Auto" would otherwise land alphabetically. Adds AgentPickerModelOrderingTest covering: a per-model pin staying inside its own provider's block, naturally interleaved provider Orders (no pin involved) still rendering one header per provider, and the router leading the list. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes model picker grouping so that models remain contiguous within their provider, even when individual models are “pinned” via a per-model Order override (as in #2331). It changes the projection sort order to group primarily by provider (with the Auto router forced to the top), and adds regression tests plus a What’s New entry documenting the user-visible fix.
Changes:
- Update
AgentPickerProjection.ProjectModelssorting to keep provider blocks contiguous, usingOrderonly as an in-provider tie-break and forcing router models first. - Add
AgentPickerModelOrderingTestto lock in contiguous provider grouping and router-first behavior. - Add a What’s New entry describing the model picker grouping fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/MeshWeaver.AI/AgentPickerProjection.cs | Changes model picker sort order to keep providers contiguous and prioritize router models. |
| test/MeshWeaver.AI.Test/AgentPickerModelOrderingTest.cs | Adds regression tests covering pinned models, interleaved orders, and router-first ordering. |
| src/MeshWeaver.Documentation/Data/WhatsNew/2026-08-26-model-picker-groups-stay-together.md | Documents the user-visible fix in the What’s New feed. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Append(null) on the (non-nullable) Provider string sequence raised CS8625 under -warnaserror, which only Release/-warnaserror catches — a plain Debug build passed. Count runs as 1 + the number of adjacent pairs whose Provider differs; no sentinel needed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Test Results (shard 3) 9 files ± 0 9 suites ±0 5m 9s ⏱️ - 1m 8s Results for commit 1fe2e3c. ± Comparison against base commit d9b59b6. This pull request removes 651 and adds 673 tests. Note that renamed tests count towards both. |
Test Results (shard 4)2 077 tests - 19 2 073 ✅ - 22 14m 33s ⏱️ + 2m 1s Results for commit 1fe2e3c. ± Comparison against base commit d9b59b6. This pull request removes 670 and adds 651 tests. Note that renamed tests count towards both. |
Summary
Orderpin (ModelOrdering.Defaults, used to promote one model to bethe deployment default) split its provider's block in the model picker, because
AgentPickerProjection.ProjectModelssorted byOrderfirst andProvidersecond. When aprovider's models don't all share one
Ordervalue, that isn't guaranteed to be contiguous — theprovider rendered under two separate headers, with the pinned model stranded at the top.
Provideris now the primary sort key (mirrorsProjectAgents'GroupName-first sort), so everyprovider's models are contiguous by construction.
Orderis the tie-break inside the group —a pin still promotes its model to the top of its own provider's block, preserving the pin's
intended effect without tearing the group apart.
Auto) is pinned ahead of every concrete provider via an explicitIsRouter-firstkey, preserving its documented "sorts ahead of everything" intent (
RouterOrder = -10) regardlessof where "Auto" would otherwise land alphabetically.
ObserveDefaultComposer's default-selectionlogic re-sorts by
Orderindependently of this display order, so default resolution isunaffected.
Coordination check (per AGENTS.md)
MeshWeaver.AIis being carved out of core in a separate live effort (#2276). Checkedgit log origin/main -- src/MeshWeaver.AIand every open PR's file list before editing — nonetouch
AgentPickerProjection.cs. Diff is scoped to that file, its test, and one What's New entry.Related: #1880 (already closed separately)
While investigating, re-verified #1880 ("duplicate/mislabelled Azure Foundry provider group") end
to end and found all of it already resolved — not by this PR, so I closed it directly rather
than lumping it in here:
(merged 2026-08-19). The old grouping mechanism that issue investigated
(
ThreadChatView.razor.cs's path-basedArrangePickerGroups) no longer exists in this repo — itleft with Delete Blazor and the portal GUI from core #2293. Today's
AgentPickerProjection.ProjectModelsgroups by theProviderstringfield, not by splitting the node path, so defect 2's failure mode can't recur by construction;
AgentPickerModelOrderingTest(added here) exercises slash-containing ids for coverage againstthe current mechanism, replacing the regression test that moved out with the Blazor GUI.
Provider/Azure/Provider/AzureFoundrynodes) was data. Verified live viaMCP:
Provider/Azureno longer exists, andProvider/AzureFoundrynow carriesname: "Azure Foundry"— both edits the issue asked for are done.Test plan
dotnet build src/MeshWeaver.AI/MeshWeaver.AI.csproj -c Release -warnaserror— cleandotnet build test/MeshWeaver.AI.Test/MeshWeaver.AI.Test.csproj -c Release -warnaserror— cleanAgentPickerModelOrderingTest(3 tests) — green, pins: a pinned model stays inside itsown provider's block; naturally interleaved provider Orders (no pin) still render one header
per provider; the router leads regardless of alphabetical position
AgentPickerQueryTest,AgentPickerQueriesTest,AgentPickerDeduplicationTest,AgentPickerUtilityFilterTest,AgentRosterContentShapeTest,AiResolutionSeamAuditTest,BuiltInLanguageModelProviderTest,AutoModelRouterTest,AutoRouterDispatchTest,ChatClientCredentialResolverTest,ModelTierCatalogTest,ModelPriceCatalogTest) — all green, no regressionsWhatsNewEntryIntegrityTest/DocumentationLinkIntegrityTest— green after adding theWhat's New entry
🤖 Generated with Claude Code