This repository was archived by the owner on May 26, 2026. It is now read-only.
Repository navigation
Commit 615f90d
Fail-fast on chatgpt OAuth in llm-caller, with targeted user guidance
Production validation B-1 (2026-04-08) found that the chatgpt OAuth
`tokens.access_token` from ~/.codex/auth.json fails when used as an
OpenAI API key:
401 You have insufficient permissions for this operation.
Missing scopes: model.request.
The chatgpt OAuth token authenticates against chatgpt.com's backend
(different wire format and endpoint set than the public OpenAI API).
Treating it as an OpenAI API key was structurally wrong: the codex CLI
uses it via its own backend, but onto's llm-caller calls the public
OpenAI SDK, which only accepts proper sk-... API keys.
The previous fallback at llm-caller.ts:99-105 was silently broken —
operators discovered the failure only at first LLM call, and the error
message was the unhelpful 401 from the SDK.
Fix:
1. Remove the OAuth `tokens.access_token` branch from resolveProvider.
Only the `OPENAI_API_KEY` field of ~/.codex/auth.json is honored
now (api-key mode of `codex login`).
2. Detect chatgpt OAuth presence (auth_mode=chatgpt or tokens.access_token
field) and surface a TARGETED error message that:
- Names chatgpt OAuth explicitly so the user knows what's wrong
- Explains WHY it doesn't work (wrong backend)
- Suggests three working alternatives (ANTHROPIC_API_KEY,
OPENAI_API_KEY env, or `codex login` in api-key mode)
3. Fall through to a generic no-provider error when neither auth.json
nor any env var has a usable credential. The generic message also
notes that chatgpt OAuth mode is not supported, so users with codex
CLI installed in chatgpt mode see clear guidance.
E2E coverage:
- E-P49 verifies the chatgpt OAuth detection error message
- E-P50 verifies the api-key mode of auth.json still works (regression
guard via mock LLM provider)
The new error path was verified end-to-end:
$ HOME=<fake home with chatgpt auth.json> npx tsx <test>
Error: No LLM API key available for learning extraction. Detected
~/.codex/auth.json with chatgpt OAuth (auth_mode=chatgpt), but the
OAuth access_token cannot authenticate against api.openai.com (it's
a chatgpt.com backend token). Set ANTHROPIC_API_KEY or OPENAI_API_KEY
(a real sk-... key), or re-run `codex login` and choose API key mode
instead of chatgpt OAuth.
Tests: 52/52 PASS (was 50). tsc clean.
This was identified as a known issue during the post-PR-review audit
of onto-harness's codex usage paths. The audit also confirmed that all
other codex integration points are clean: subagent-review-unit-executor
spawns `codex` from PATH (no plugin path assumption), agent-teams
delegates to child Claude (cross-plugin handled by child), and
detection logic uses standard CODEX_THREAD_ID/CODEX_CI env vars.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>1 parent dc7f111 commit 615f90d
2 files changed
Lines changed: 159 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2051 | 2051 | | |
2052 | 2052 | | |
2053 | 2053 | | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
2054 | 2161 | | |
2055 | 2162 | | |
2056 | 2163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
12 | 35 | | |
13 | 36 | | |
14 | 37 | | |
| |||
60 | 83 | | |
61 | 84 | | |
62 | 85 | | |
63 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
64 | 89 | | |
65 | 90 | | |
66 | 91 | | |
| |||
81 | 106 | | |
82 | 107 | | |
83 | 108 | | |
84 | | - | |
85 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
86 | 115 | | |
87 | 116 | | |
88 | 117 | | |
89 | 118 | | |
90 | | - | |
91 | 119 | | |
92 | 120 | | |
93 | 121 | | |
94 | 122 | | |
95 | 123 | | |
96 | 124 | | |
97 | 125 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
105 | 132 | | |
106 | 133 | | |
107 | | - | |
| 134 | + | |
| 135 | + | |
108 | 136 | | |
109 | 137 | | |
110 | 138 | | |
| |||
117 | 145 | | |
118 | 146 | | |
119 | 147 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
124 | 159 | | |
125 | 160 | | |
126 | 161 | | |
| |||
0 commit comments