Skip to content

refactor(rulebased): remove the client-wide lastSelectedID - #4710

Merged
aheritier merged 1 commit into
mainfrom
refactor/rulebased-last-selected
Oct 23, 2026
Merged

aheritier merged 1 commit into
mainfrom
refactor/rulebased-last-selected

Conversation

@aheritier

Copy link
Copy Markdown
Collaborator

Closes #4684. Follow-up from epic #4580.

What

This PR removes rulebased.Client.lastSelectedID and its LastSelectedModelID() 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 ServingModel instead, and no production code read the accessor any more.

File Change
pkg/model/provider/rulebased/client.go Field, Store and accessor removed; the CreateChatCompletionStream doc now points to the stream's ServingModel
pkg/model/provider/rulebased/client_race_test.go TestLastSelectedModelID_Concurrent becomes TestServingModel_ConcurrentRoutes: 100 concurrent requests on one router, each stream reporting its own route. Only the goroutine reading the removed accessor is gone
pkg/runtime/routing_pricing_test.go One redundant assertion dropped from the fallback case: leaf.callCount == 1 beside it already proves the route was selected, and the persisted model and cost assertions cover pricing

Validation

  • task build passes.
  • golangci-lint v2.14.0 reports 0 issues, and go run ./lint . reports no offenses.
  • go test -race passes on pkg/model/provider/rulebased, pkg/model/provider, pkg/runtime and pkg/tui/... (routing, pricing and sidebar).
  • git grep "LastSelectedModelID\|lastSelectedID" -- '*.go' returns nothing.

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>
@aheritier
aheritier requested a review from a team as a code owner October 22, 2026 19:17
Copilot AI balanced review requested due to automatic review settings October 22, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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
aheritier enabled auto-merge October 22, 2026 19:18
@aheritier aheritier added area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) kind/refactor PR refactors code without behavior change labels Oct 22, 2026
@aheritier
aheritier added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit de01fc1 Oct 23, 2026
17 checks passed
@aheritier
aheritier deleted the refactor/rulebased-last-selected branch October 23, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(rulebased): remove the client-wide lastSelectedID

3 participants