Commit 51864b0
authored
feat: use run agent task auth for inference (#19051)
## Stack
This is PR 3 of the simplified HAI single-run-task stack:
- [#19047](#19047) Agent Identity
assertion and task-registration primitives, including the shared
run-task helper used by existing Agent Identity JWT auth.
- [#19049](#19049)
Disabled-by-default ChatGPT auth opt-in that provisions/reuses persisted
Agent Identity runtime auth and its single run task.
- [#19051](#19051) Run-scoped
provider auth that uses one backend-owned task id for first-party
inference and compaction requests.
[#19054](#19054) collapsed out of
the active stack because the simplified design no longer needs a
separate background/control-plane task helper.
## Summary
This PR moves Agent Identity usage into provider auth resolution. That
keeps `AgentAssertion` auth tied to first-party OpenAI provider requests
instead of applying a late session-wide override that could affect
local, custom, Bedrock, API-key, or external-bearer providers.
What changed:
- adds a small `ProviderAuthScope` struct carrying the run auth policy
and session source needed by provider-scoped auth resolution
- lets `Session` opt the existing `ModelClient` into `ChatGptAuth`
policy when `use_agent_identity` is enabled, without adding a second
model-client constructor
- resolves Agent Identity only for first-party OpenAI provider auth
paths
- uses the persisted run task id from the `AgentIdentityAuth` record to
build `AgentAssertion` auth for Responses requests
- routes shared request setup through scoped provider auth so unary
compact requests use the same run-task assertion path as inference turns
- keeps local/custom/Bedrock/env-key/external-bearer provider auth
unchanged
- lets missing run-task state surface through the existing model-request
error path instead of silently falling back to bearer auth
This PR intentionally does not create thread-scoped, target-scoped, or
background-scoped task identities. The run task is the only task Codex
registers in this POC shape.
## Testing
- `just test -p codex-model-provider`
- `just test -p codex-core client::tests::provider_auth_scope_uses`
- `just test -p codex-core remote_compact_uses_agent_identity_assertion`1 parent f66d793 commit 51864b0
22 files changed
Lines changed: 1020 additions & 20 deletions
File tree
- codex-rs
- codex-api/src
- core
- src
- session
- tests
- suite
- login/src/auth
- memories/write/src
- model-provider/src
- otel
- src/events
- tests/suite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
| 122 | + | |
| 123 | + | |
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
| |||
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
| 209 | + | |
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
| |||
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| 221 | + | |
216 | 222 | | |
217 | 223 | | |
218 | 224 | | |
| |||
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
| 249 | + | |
243 | 250 | | |
244 | 251 | | |
245 | 252 | | |
| |||
392 | 399 | | |
393 | 400 | | |
394 | 401 | | |
| 402 | + | |
395 | 403 | | |
396 | 404 | | |
397 | 405 | | |
| |||
426 | 434 | | |
427 | 435 | | |
428 | 436 | | |
| 437 | + | |
429 | 438 | | |
430 | 439 | | |
| 440 | + | |
431 | 441 | | |
432 | 442 | | |
433 | 443 | | |
| |||
528 | 538 | | |
529 | 539 | | |
530 | 540 | | |
| 541 | + | |
531 | 542 | | |
532 | 543 | | |
533 | 544 | | |
| |||
660 | 671 | | |
661 | 672 | | |
662 | 673 | | |
| 674 | + | |
663 | 675 | | |
664 | 676 | | |
665 | 677 | | |
| |||
909 | 921 | | |
910 | 922 | | |
911 | 923 | | |
912 | | - | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
913 | 933 | | |
914 | 934 | | |
915 | 935 | | |
916 | | - | |
| 936 | + | |
| 937 | + | |
917 | 938 | | |
918 | 939 | | |
919 | 940 | | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
920 | 945 | | |
921 | 946 | | |
922 | 947 | | |
| |||
934 | 959 | | |
935 | 960 | | |
936 | 961 | | |
937 | | - | |
| 962 | + | |
938 | 963 | | |
939 | 964 | | |
940 | 965 | | |
| |||
976 | 1001 | | |
977 | 1002 | | |
978 | 1003 | | |
| 1004 | + | |
979 | 1005 | | |
980 | 1006 | | |
981 | 1007 | | |
| |||
1205 | 1231 | | |
1206 | 1232 | | |
1207 | 1233 | | |
| 1234 | + | |
1208 | 1235 | | |
1209 | 1236 | | |
1210 | 1237 | | |
| |||
1343 | 1370 | | |
1344 | 1371 | | |
1345 | 1372 | | |
| 1373 | + | |
1346 | 1374 | | |
1347 | 1375 | | |
1348 | 1376 | | |
| |||
1470 | 1498 | | |
1471 | 1499 | | |
1472 | 1500 | | |
| 1501 | + | |
1473 | 1502 | | |
1474 | 1503 | | |
1475 | 1504 | | |
| |||
2035 | 2064 | | |
2036 | 2065 | | |
2037 | 2066 | | |
2038 | | - | |
| 2067 | + | |
2039 | 2068 | | |
2040 | 2069 | | |
2041 | 2070 | | |
2042 | 2071 | | |
| 2072 | + | |
2043 | 2073 | | |
2044 | 2074 | | |
2045 | 2075 | | |
| |||
2049 | 2079 | | |
2050 | 2080 | | |
2051 | 2081 | | |
| 2082 | + | |
2052 | 2083 | | |
2053 | 2084 | | |
2054 | 2085 | | |
| |||
2062 | 2093 | | |
2063 | 2094 | | |
2064 | 2095 | | |
| 2096 | + | |
2065 | 2097 | | |
2066 | 2098 | | |
2067 | 2099 | | |
2068 | 2100 | | |
2069 | 2101 | | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
2070 | 2106 | | |
2071 | 2107 | | |
2072 | 2108 | | |
| |||
2253 | 2289 | | |
2254 | 2290 | | |
2255 | 2291 | | |
| 2292 | + | |
2256 | 2293 | | |
2257 | 2294 | | |
2258 | 2295 | | |
| |||
2307 | 2344 | | |
2308 | 2345 | | |
2309 | 2346 | | |
| 2347 | + | |
2310 | 2348 | | |
2311 | 2349 | | |
2312 | 2350 | | |
| |||
0 commit comments