Repository navigation
Commit 3f555f9
feat: narrow models to what the providers/set gateway lists (#627)
### Summary
Addresses [IJAI-1783](https://youtrack.jetbrains.com/issue/IJAI-1783).
An organization can restrict the models its JetBrains gateway serves,
but a session routed through `providers/set` offered Codex's whole
catalogue, so the picker showed models the gateway then refused.
`providers/set` now lists the gateway's models before it responds, and
the adapter reports only the Codex models the gateway lists.
- `GET {baseUrl}/models` with the headers Codex sends to the gateway
(`X-Client-Feature-ID: codex` plus the `providers/set` headers); OpenAI
format, `data[].id`. The listing is stored with the gateway config, so a
provider restart reuses it, and setting the same configuration again
does not list again.
- `fetchAvailableModels` narrows `model/list`, so new, resumed, loaded
and forked sessions and `unstable_setSessionModel` all see the same
list. Ids match without case and date suffix; exactly one narrowed model
stays `isDefault`.
- A thread model the gateway does not list is replaced by the narrowed
default, also on `turn/start`; a model the gateway lists but Codex's
catalogue lacks is kept. Sessions open across `providers/set` or
`providers/disable` take the models of the restarted app-server, and the
client gets a `config_option_update`. A listing that matches no Codex
model leaves the session with no model: there is no model config option
at all.
- A 4xx answer means the gateway has no listing: `providers/set`
succeeds and nothing is narrowed. Any other failed listing (network
error, 5xx, malformed body, 10 s timeout) fails `providers/set` with
`internal_error`, and the current routing stays. A listing that finishes
after a newer `providers/set` or `providers/disable` was applied is
dropped (a newer request that failed drops nothing), and the routing
goes to the client a provider restart installed. A `baseUrl` that is not
an http(s) URL, accepted on v1 before, now fails with `invalid_params`;
an invalid header or a base URL with credentials fails without repeating
the value.
- The `gateway` auth method and providers from the Codex config
(`config.toml`, `CODEX_CONFIG`) are not listed. `readme-dev.md`
describes the behaviour.
### Not covered
Title generation (`gpt-5.6-luna`), subagents, `/review` and compaction
choose their own model and are not checked against the listing.
### Verification
```bash
npm run typecheck
npm run build
npm test # 1755 passed, 36 skipped
```
`gateway-model-discovery.test.ts` covers the request and headers,
narrowing and the default, the replaced thread model on `turn/start`,
failing `providers/set` (HTTP error, malformed body, network error) with
the routing kept, the empty list, no listing without `providers/set` or
for the gateway auth method, `providers/disable`, reuse, and the
provider restart. Tests that call `providers/set` stub the listing
(`stubGatewayModelListing`). Checked locally against the JetBrains
gateway with an earlier build of this branch: the adapter's log shows
`/models` answering `gpt-5.6-sol`, `gpt-6-sol`, `gpt-6.1-sol` in one
session and an empty list with only Bedrock configured; the empty-list
and failing-listing behaviour of the final build is covered by the tests
only.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent a636804 commit 3f555f9
12 files changed
Lines changed: 858 additions & 88 deletions
File tree
- src
- __tests__
- CodexACPAgent
- data
- app-server-recovery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
180 | 195 | | |
181 | 196 | | |
182 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| |||
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
456 | 471 | | |
457 | | - | |
458 | | - | |
| 472 | + | |
| 473 | + | |
459 | 474 | | |
460 | 475 | | |
461 | | - | |
462 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
463 | 483 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
471 | 502 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
482 | 513 | | |
483 | 514 | | |
484 | 515 | | |
| |||
525 | 556 | | |
526 | 557 | | |
527 | 558 | | |
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 | 559 | | |
553 | 560 | | |
554 | 561 | | |
| |||
812 | 819 | | |
813 | 820 | | |
814 | 821 | | |
815 | | - | |
| 822 | + | |
816 | 823 | | |
817 | 824 | | |
818 | 825 | | |
| |||
1074 | 1081 | | |
1075 | 1082 | | |
1076 | 1083 | | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1077 | 1100 | | |
1078 | 1101 | | |
1079 | 1102 | | |
| |||
1342 | 1365 | | |
1343 | 1366 | | |
1344 | 1367 | | |
| 1368 | + | |
1345 | 1369 | | |
1346 | 1370 | | |
1347 | 1371 | | |
| |||
1352 | 1376 | | |
1353 | 1377 | | |
1354 | 1378 | | |
1355 | | - | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1356 | 1390 | | |
1357 | 1391 | | |
1358 | 1392 | | |
| |||
1437 | 1471 | | |
1438 | 1472 | | |
1439 | 1473 | | |
1440 | | - | |
| 1474 | + | |
1441 | 1475 | | |
1442 | 1476 | | |
1443 | 1477 | | |
1444 | 1478 | | |
1445 | 1479 | | |
1446 | 1480 | | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1447 | 1505 | | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
1448 | 1532 | | |
1449 | 1533 | | |
1450 | 1534 | | |
| |||
0 commit comments