mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-24 16:12:23 +03:00
The reactively-learned reasoning-effort clamp (clampToLearned, populated from upstream 4xx enum errors on custom/unregistered provider+model pairs) used downgrade-only semantics — greatest accepted value <= demand. The statically- declared clamp (registry supportedThinkingEfforts, sanitizeReasoningEffortForProvider) already used nearest-tier semantics — smallest accepted value >= demand, falling back to the ceiling when demand exceeds every accepted value (#11274's DeepSeek native mapping is the precedent for that direction). For the identical accepted set, e.g. {low, high, max}, the two paths disagreed: a request for "medium" clamped to "low" via the learned path but "high" via the declared path — same inputs, opposite outputs, depending only on whether the model happened to have a static registry entry. The owner decided to unify on nearest-tier for both. This also fixes a standalone bug in the old learned clamp: a request BELOW the learned floor (e.g. none/minimal on a model that only ever advertised {low,high,max}) returned null (no clamp), so the too-low value reached the upstream unchanged and 400'd again on every subsequent request without ever learning a lower floor. Nearest-tier fixes this for free: the smallest accepted value is always >= any demand below the floor. Risk: the learned-cap Map is in-memory and resets on every deploy, but while populated this changes user-visible clamped values for providers that have already been reactively taught an accepted set — e.g. a provider previously serving "low" for a "medium" request now serves "high" instead. Realigned pre-existing tests in tests/unit/learned-reasoning-effort-caps.test.ts, tests/unit/reasoning-effort-clamp-and-retry.test.ts, and tests/unit/reasoning-effort-learned-capability.test.ts that asserted the old downgrade-only direction (all from #11232 and earlier). Added tests/unit/reasoning-effort-clamp-direction-consistency.test.ts asserting the learned and declared paths now map the same accepted set identically, and that a sub-floor demand clamps up instead of passing through unmapped.