Repository navigation
Commit d5f359e
opensecret: health-aware Auto model selection for Router V2 (#968)
* opensecret: health-aware Auto model selection for Router V2
Router V2 resolved an Auto alias to one public model before any health
check, so a single-route model with no eligible provider left Auto Quick
with nothing to do. Add a small compiled Auto model policy that runs after
alias resolution and before any model-dependent work: paid Quick may move
from DeepSeek V4.1 Flash to GLM 5.3 Flash and paid Powerful from GLM 5.3 to
Kimi K3 only when every route of the preferred model is unavailable under
that model's own failover policy. Free tiers keep their single target,
explicit selections never change public model, and Router V1 is untouched.
The decision consumes one health snapshot across all candidate routes,
claims nothing, and feeds the chosen model into the existing same-model
planner, first-send claim, tool-loop pinning, persistence, and usage. An
alternate is skipped when the request needs more context than its window
(Chat uses a text-only estimate with a byte bound before tokenizing, plus
tool schemas and the caller's output limit), when it lacks vision the
request needs, or, for Kimi on Chat, when tool-call ids are not in Kimi
form. Before any provider send, a chosen Auto model that cannot hold the
request's context or loses its routes earns exactly one further decision
with that model excluded; nothing is ever replayed after a send starts.
Router V2 also remembers the route a provider accepted per account,
surface, and selector for one idle hour so warmed prompt caches are reused:
the planner prefers the remembered same-model provider while eligible, and
Auto retries the remembered alternate before the preferred model while it
stays healthy. Responses now binds the user key, conversation ownership,
the usage gate, and the caller's message against the tier's own model
before the decision; its input handling is split so the budget check and
both context builds use the final model.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* opensecret: keep the capacity result when Auto reselection has no alternate
A bounded second Auto decision excluded the lost model as a context
overflow even when the cause was a route that became unavailable after
the first snapshot. With no other candidate (free Quick, or a paid tier
whose alternate is incompatible) the selector reported no health rejection
and the request ended as a 500 instead of the typed capacity result, losing
the retry hint although nothing had been sent.
Carry the exclusion cause: a lost route is excluded as unavailable with the
capacity result's own retry hint, so the second decision reports it and
keeps the 503 contract and Retry-After; a context overflow stays distinct.
The Responses replay-safety downgrade after billed image helpers still
applies. Tests cover free single-candidate Auto and paid Auto with an
incompatible alternate on both surfaces, the hint fallback, the compatible
alternate still being taken once, and the helper downgrade.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>1 parent 77b92f5 commit d5f359e
13 files changed
Lines changed: 4180 additions & 201 deletions
File tree
- .agents/skills/change-opensecret-provider
- services/opensecret/src
- inference
- web
- responses
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
99 | 120 | | |
100 | 121 | | |
101 | 122 | | |
| |||
148 | 169 | | |
149 | 170 | | |
150 | 171 | | |
151 | | - | |
| 172 | + | |
152 | 173 | | |
153 | 174 | | |
154 | 175 | | |
| |||
464 | 485 | | |
465 | 486 | | |
466 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
467 | 530 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
28 | 41 | | |
29 | 42 | | |
30 | | - | |
| 43 | + | |
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
| |||
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
| 83 | + | |
70 | 84 | | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
72 | 91 | | |
73 | 92 | | |
74 | 93 | | |
| |||
91 | 110 | | |
92 | 111 | | |
93 | 112 | | |
| 113 | + | |
94 | 114 | | |
95 | 115 | | |
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
99 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
100 | 144 | | |
101 | 145 | | |
102 | 146 | | |
| |||
0 commit comments