Repository navigation
Commit 3b35338
authored
fix: skip the app-server restart when providers/set repeats the applied config (#728)
## Summary
Fixes [IJAI-5588](https://youtrack.jetbrains.com/issue/IJAI-5588). A
`providers/set` that sent the same values as the routing already in
effect still restarted the Codex app-server whenever a session was open.
Codex writes a thread to disk only on its first model turn, so it cannot
resume a session that has not had one: a new session, or one that only
ran an adapter-handled command such as `/mcp`. After the restart, every
prompt in such a session failed with "had no messages yet and was lost".
AIR sends such a repeated `providers/set` after a policy refresh briefly
reports no routes.
- `setProvider` skips the restart when the new provider config equals
the one the last `providers/set` applied. A repeated request still waits
for a provider update in flight and only then responds, so a success
response still means the routing is in effect.
- After a failed provider update, the same request restarts again (new
`providerUpdateFailed` flag). Without it, retrying a failed
`providers/set` would report success with nothing applied.
- `sameGatewayRouting` (base URL, wire API and headers) becomes
`sameProviderConfig`: `modelProvider` plus the whole `config`, compared
by value with `util.isDeepStrictEqual`. A field added to `config` later
is compared without changes here. `prepareProvider` reuses the previous
model listing through the same check (`hasProviderRouting`), so the
listing reuse and the restart skip cannot drift apart.
- `readme-dev.md` documents the behavior.
A real routing change still loses sessions that have no model turn, as
before. That is a Codex limitation and is already documented.
`providers/disable` still always restarts; the real-Codex e2e test
`hooks.test.ts` relies on that.
## Validation
- `npm run typecheck`: passed
- `npm test`: 2,419 passed, 39 skipped
- `git diff --check`: passed
- New tests in `src/__tests__/app-server-recovery/recovery.test.ts`: a
session with no messages survives a repeated `providers/set` while a
changed header still restarts; a repeated request during a running
restart responds only after it. Both fail with the skip turned off.
- The existing test "counts provider restarts whose handshake fails"
covers the retry after a failed update.
`CodexHomeWatcher.test.ts` ("reports a rollout that another process
moved into archived_sessions…") failed in 2 of 4 full runs on this
branch and passes when run alone. It does not touch providers.1 parent e059ab7 commit 3b35338
4 files changed
Lines changed: 75 additions & 11 deletions
File tree
- src
- __tests__/app-server-recovery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
474 | | - | |
| 475 | + | |
475 | 476 | | |
476 | | - | |
477 | | - | |
478 | | - | |
| 477 | + | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
491 | 498 | | |
492 | 499 | | |
493 | 500 | | |
| |||
1614 | 1621 | | |
1615 | 1622 | | |
1616 | 1623 | | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
1617 | 1628 | | |
1618 | 1629 | | |
1619 | 1630 | | |
| |||
1665 | 1676 | | |
1666 | 1677 | | |
1667 | 1678 | | |
1668 | | - | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1675 | 1685 | | |
1676 | 1686 | | |
1677 | 1687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
| 560 | + | |
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
| |||
2294 | 2296 | | |
2295 | 2297 | | |
2296 | 2298 | | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
2297 | 2306 | | |
2298 | 2307 | | |
2299 | 2308 | | |
| |||
2429 | 2438 | | |
2430 | 2439 | | |
2431 | 2440 | | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
2432 | 2446 | | |
2433 | 2447 | | |
2434 | 2448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
520 | 557 | | |
521 | 558 | | |
522 | 559 | | |
| |||
0 commit comments