Commit d6b6c89
authored
The failover resolver (PR-D) had no production caller: chat.py still picked
the first enabled provider directly, so model_defaults.candidates order and
cooldown were dead UI surface.
- chat endpoint: when the chat role has model_defaults.candidates, run
through resolve_with_fallback() — connection-level failures (connect
error/timeout/5xx, decision #7) fail over to the next candidate, business
failures (4xx) re-raise immediately. Explicit provider_id and roles with
no candidates keep the legacy single-provider path unchanged.
- tool loops (JSON + XML) now raise LlmAdapterError with classify_retryable
instead of a bare 502, so the resolver can distinguish failover-worthy
failures; 502 conversion stays at the endpoint boundary.
- resolver: skip disabled providers in resolve()/resolve_with_fallback()
(governance choice, not liveness failure — no cooldown), add public
has_candidates() for the legacy fallback branch.
- tests: unit coverage for disabled-skip + has_candidates; new
tests/integration/test_chat_failover_api.py exercises the production
chain through POST /api/v1/chat (legacy path, retryable failover,
business-error no-failover, all-unavailable 502, disabled-skip,
explicit-provider bypass).
- fix latent patch leak in test_resolver concurrency test (per-task
unittest.mock.patch around an await races under asyncio.gather and leaked
a get_adapter mock into later tests).
1 parent 9092fa5 commit d6b6c89
4 files changed
Lines changed: 490 additions & 21 deletions
File tree
- backend
- api/v1
- llm
- tests
- integration
- unit/llm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
341 | 343 | | |
342 | 344 | | |
343 | 345 | | |
344 | | - | |
345 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
346 | 349 | | |
347 | | - | |
348 | | - | |
| 350 | + | |
| 351 | + | |
349 | 352 | | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
354 | 365 | | |
355 | 366 | | |
356 | 367 | | |
| |||
366 | 377 | | |
367 | 378 | | |
368 | 379 | | |
| 380 | + | |
| 381 | + | |
369 | 382 | | |
370 | 383 | | |
371 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 | | |
373 | 388 | | |
374 | 389 | | |
| |||
413 | 428 | | |
414 | 429 | | |
415 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
416 | 486 | | |
417 | 487 | | |
418 | 488 | | |
| |||
502 | 572 | | |
503 | 573 | | |
504 | 574 | | |
| 575 | + | |
| 576 | + | |
505 | 577 | | |
506 | 578 | | |
507 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
508 | 582 | | |
509 | 583 | | |
510 | 584 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
105 | 117 | | |
106 | 118 | | |
107 | 119 | | |
108 | 120 | | |
109 | | - | |
| 121 | + | |
110 | 122 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 | | |
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | | - | |
| 135 | + | |
123 | 136 | | |
124 | 137 | | |
125 | 138 | | |
| |||
140 | 153 | | |
141 | 154 | | |
142 | 155 | | |
143 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
144 | 160 | | |
145 | 161 | | |
146 | 162 | | |
| |||
170 | 186 | | |
171 | 187 | | |
172 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
173 | 194 | | |
174 | 195 | | |
175 | 196 | | |
| |||
0 commit comments