Commit 6c975c5
authored
fix(dash): prefer a local chat server over the cloud default at startup (#100)
* fix(dash): prefer a local chat server over the cloud default at startup
Startup only single-probed DEFAULT_CHAT_BASE_URL (:8000) before falling
back to the ChatGPT cloud OAuth flow, even though the manual 'd' detect
path already knew how to find a local engine on any of its well-known
ports (Lemonade :13305, vLLM :8000, rocm serve :11435) plus the
managed-services registry. A server running on any port other than
:8000 was invisible at startup and users landed in the cloud login flow
instead.
Reuse detect_local_chat() (registry-first, then the 3-port probe, then
a best-effort model fetch) in the startup branch that already gated on
"no explicit chat_url/env_url configured" — the same condition that
previously ran only detect_managed_chat(). Parallelize
llm::detect_local_endpoint()'s port probe (std::thread::scope) so a
cold start with nothing listening still costs one PROBE_TIMEOUT
(~300ms) instead of three, keeping startup latency bounded.
Unmerged PR #97 also touches this startup branch (model discovery
inside resolve_llm_config's own fallback when chat_model is None);
this change is conflict-minimal — it swaps detect_managed_chat for
detect_local_chat without touching the resolve_llm_config call itself.
Relates to EAI-7347.
Signed-off-by: Michael Roy <michael.roy@amd.com>
* fix(chat): do not run local-detection swap when an api key is configured
Startup local-engine detection returns a keyless detected_llm_config
(api_key/auth_header forced to None). Firing it whenever no explicit
URL was set — even when the user configured OPENAI_API_KEY /
ROCMDASH_CHAT_API_KEY — silently dropped that credential and produced a
401 at request time.
Gate detection on chat_api_key.is_none() as well (extracted into the
pure should_detect_local_chat helper for unit testing): a configured
key means "use my configured backend", so skip the swap and let
resolve_llm_config carry the key through its normal precedence.
Also skip the redundant fallback probe: when detection ran and found
nothing it already probed the well-known vLLM :8000 port (==
DEFAULT_CHAT_BASE_URL), so re-probing that same target just burned
another PROBE_TIMEOUT on a no-server cold start; treat it as
unreachable directly.
Relates to EAI-7347.
Signed-off-by: Michael Roy <michael.roy@amd.com>
* fix(dash): guard well-known ports free in local-detect port-priority tests
detect_local_chat_prefers_local_server_over_no_endpoint (and the sibling
detect_local_endpoint_probes_rocm_serve_default_port) only bound the
rocm-serve port and assumed the higher-priority Lemonade/vLLM ports were
unreachable. On the Windows CI runner that isn't guaranteed, so an
ambient listener on :13305 or :8000 made detection return that endpoint
instead of rocm-serve's, failing the assertion.
Both tests now bind-and-release the higher-priority ports first to
confirm they're free before asserting on the rocm-serve fallback.
Signed-off-by: Michael Roy <michael.roy@amd.com>
* fix(dash): make local-detect priority tests port-independent
The previous fix (bind-then-release the higher-priority ports before
asserting) still flaked on the Windows CI runner: something answered on
the Lemonade port during the probe despite the guard, most likely an
ambient listener the test doesn't control. TCP-connect-based detection
means any listener on a well-known port — even a bare guard listener
held open, as the very first attempt at this fix did — registers as
"reachable", so real ports can't be made deterministic from a test.
Split the port-priority logic in llm.rs into probe_first_reachable,
tested directly against OS-assigned ephemeral ports instead of the real
well-known ports. Gave detect_local_chat an injectable probe seam
(detect_local_chat_with_probe) so its own test can verify the
no-managed-executor wiring without depending on any real network state.
Signed-off-by: Michael Roy <michael.roy@amd.com>
* fix(dash): widen latency margin in detect_local_endpoint timing test
detect_local_endpoint_bounded_latency_when_nothing_listening's 2x
PROBE_TIMEOUT margin was still too tight for the Windows CI runner
(observed 624ms against a 600ms threshold). A true sequential-probing
regression takes ~3x PROBE_TIMEOUT, so widen the margin to 4x to absorb
scheduling jitter on slower CI machines while still catching that
regression.
Signed-off-by: Michael Roy <michael.roy@amd.com>
* test(dash): strengthen local chat startup coverage
Signed-off-by: Michael Roy <michael.roy@amd.com>
---------
Signed-off-by: Michael Roy <michael.roy@amd.com>1 parent 5d73191 commit 6c975c5
3 files changed
Lines changed: 269 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
231 | 242 | | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
235 | 246 | | |
236 | 247 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 248 | + | |
241 | 249 | | |
242 | 250 | | |
243 | 251 | | |
| |||
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
249 | 295 | | |
250 | 296 | | |
251 | 297 | | |
| |||
408 | 454 | | |
409 | 455 | | |
410 | 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 | + | |
| 486 | + | |
| 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 | + | |
411 | 517 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
| 42 | + | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
1562 | 1562 | | |
1563 | 1563 | | |
1564 | 1564 | | |
1565 | | - | |
1566 | | - | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
1567 | 1593 | | |
1568 | 1594 | | |
1569 | 1595 | | |
| |||
1572 | 1598 | | |
1573 | 1599 | | |
1574 | 1600 | | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1580 | 1612 | | |
1581 | 1613 | | |
1582 | 1614 | | |
1583 | | - | |
| 1615 | + | |
1584 | 1616 | | |
1585 | | - | |
| 1617 | + | |
1586 | 1618 | | |
1587 | 1619 | | |
1588 | 1620 | | |
| |||
1599 | 1631 | | |
1600 | 1632 | | |
1601 | 1633 | | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
| 1634 | + | |
1606 | 1635 | | |
1607 | 1636 | | |
1608 | 1637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 191 | + | |
| 192 | + | |
194 | 193 | | |
195 | | - | |
196 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
197 | 232 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 233 | + | |
205 | 234 | | |
206 | 235 | | |
207 | 236 | | |
| |||
438 | 467 | | |
439 | 468 | | |
440 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
441 | 485 | | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
| 486 | + | |
| 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 | + | |
450 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
451 | 540 | | |
452 | | - | |
453 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
454 | 547 | | |
455 | | - | |
456 | 548 | | |
457 | 549 | | |
0 commit comments