Repository navigation
refactor(rulebased): remove the client-wide lastSelectedID - #4710
Merged
Merged
Conversation
One router serves every conversation of a team load, so the most recent selection mixed conversations. Since #4579 accounting and the UI read the per-stream ServingModel, and nothing read LastSelectedModelID. Keep its race test as a check that concurrent streams each report their own route. Closes #4684 Signed-off-by: Arnaud Héritier <aheritier@apache.org>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow cleanup leaves no dangling references and preserves per-stream identity handling and relevant regression checks.
No open issues 🎉
What changed in this PR
Removes obsolete client-wide routing state, leaving per-stream ServingModel as the source of routed model identity. This completes #4684 and follows the accounting changes in #4579.
Changes:
- Removes
lastSelectedID, its accessor, and unused imports. - Preserves concurrent per-stream route checks under a renamed test.
- Removes the obsolete accessor assertion while retaining fallback pricing checks.
| File | Description |
|---|---|
pkg/runtime/routing_pricing_test.go |
Removes the obsolete assertion; retains route-count and pricing checks. |
pkg/model/provider/rulebased/client.go |
Removes shared last-selection state and documents per-stream identity. |
pkg/model/provider/rulebased/client_race_test.go |
Renames the concurrency test and removes accessor reads. |
Review effort: Balanced
aheritier
enabled auto-merge
October 22, 2026 19:18
trungutt
approved these changes
Oct 23, 2026
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.
Closes #4684. Follow-up from epic #4580.
What
This PR removes
rulebased.Client.lastSelectedIDand itsLastSelectedModelID()accessor.A provider client is built once per team load and shared by every conversation ("Client and Session Lifetimes" in AGENTS.md). So "the route chosen by the most recent request" mixed conversations. Since #4579, accounting and the UI read the per-stream
ServingModelinstead, and no production code read the accessor any more.pkg/model/provider/rulebased/client.goStoreand accessor removed; theCreateChatCompletionStreamdoc now points to the stream'sServingModelpkg/model/provider/rulebased/client_race_test.goTestLastSelectedModelID_ConcurrentbecomesTestServingModel_ConcurrentRoutes: 100 concurrent requests on one router, each stream reporting its own route. Only the goroutine reading the removed accessor is gonepkg/runtime/routing_pricing_test.gofallbackcase:leaf.callCount == 1beside it already proves the route was selected, and the persisted model and cost assertions cover pricingValidation
task buildpasses.golangci-lintv2.14.0 reports 0 issues, andgo run ./lint .reports no offenses.go test -racepasses onpkg/model/provider/rulebased,pkg/model/provider,pkg/runtimeandpkg/tui/...(routing, pricing and sidebar).git grep "LastSelectedModelID\|lastSelectedID" -- '*.go'returns nothing.