Skip to content

Canonicalize routing-memory score keys so model spelling cannot matter #541

Description

@njbrake

Note: this issue was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's.

fab759be fixed the reachable case: rank now rewrites each score key to the spelling its policy uses, because knn._score matches qualities keys against candidate selectors by exact string. Before that, openai/gpt-4o against a policy naming openai:gpt-4o was accepted with a 200, stored raw, never matched, and the router served the expensive model at confidence 1.0 while reporting the pool warm.

One case survives. Normalization picks a single spelling per canonical model, so if two learned policies for the same user spell one model differently, the other policy's lookup still misses:

sent: openai/gpt-3.5-turbo -> stored as: openai:gpt-3.5-turbo
policy a looks up openai:gpt-3.5-turbo => match
policy b looks up openai/gpt-3.5-turbo => miss

Narrow, and it needs two learned policies with inconsistent spellings, but the failure mode is the silent one: a warm pool that quietly never routes.

Fix the class rather than the instance: store the canonical instance:model in qualities, and canonicalize the pool at lookup in _score, so spelling cannot matter anywhere. Aliases resolve through the same path.

Follow-up from #188.

Metadata

Metadata

Assignees

Labels

area/backendBackend service implementationbugSomething isn't workingtype/tech-debtMaintenance and cleanup

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions