Repository navigation
v1.0.0 — local retry shim for the capacity error
What this is
A local retry shim that stops "Selected model is at capacity. Please try a different model." from interrupting your work.
Not a proxy service, not a shared account, not a middleman. It is a single stdlib-only Python file listening on 127.0.0.1 that forwards to the official endpoint using the OAuth token Codex already sent. Delete one line from config.toml and you are back to a direct connection.
Install
Download codex-overload-fix-1.0.0.zip below, unzip it, then:
powershell -ExecutionPolicy Bypass -File scripts\install.ps1The installer finds Python (3.9+, no dependencies), registers a hidden launcher and a watchdog, and prints the config.toml snippet to paste. No admin rights, no console window.
Then set your provider in %USERPROFILE%\.codex\config.toml:
model_provider = "openai-retry"
[model_providers.openai-retry]
name = "OpenAI (retry)"
base_url = "http://127.0.0.1:8787"
wire_api = "responses"
requires_openai_auth = true
stream_max_retries = 20
request_max_retries = 10Restart Codex. Undo with scripts\uninstall.ps1.
Prefer git clone if you want git pull updates:
git clone https://github.com/NewBeeM4n/codex-overload-fix.gitWhy the error happens
The rejection is not a quota problem. server_is_overloaded arrives as an error event inside an HTTP 200 SSE stream, so nothing that retries on status codes ever sees it. And the rejection rate tracks request body size, not model choice:
| request body | n | attempts needed (mean) | worst |
|---|---|---|---|
| < 100 KB | 20 | 1.95 | 5 |
| 100–200 KB | 24 | 1.96 | 9 |
| 200–500 KB | 23 | 1.74 | 4 |
| > 500 KB | 4 | 6.75 | 9 |
One 799 KB request failed 8 times in a row and succeeded on the 9th. The user never saw a thing.
What is in the box
| file | purpose |
|---|---|
relay/relay.py |
the shim — recognies the overload, retries only before any token is emitted, stops when you cancel |
scripts/install.ps1 / uninstall.ps1 |
hidden launcher, watchdog, config snippet |
tools/capture_server.py |
measures the exact request body your client sends |
tools/analyze_log.py |
summarises attempts vs. request size from relay.log |
docs/findings.md |
the full write-up with the measurements |
Verify the download
791c7d32ba9eb9eab50004a9cd722075ca02ee14c202a0c6a3887a28ed45afd4 codex-overload-fix-1.0.0.zip
Also attached as .sha256. You can let GitHub confirm it instead:
Get-FileHash .\codex-overload-fix-1.0.0.zip -Algorithm SHA256Known limitations
- Single machine, single account, small samples. The size correlation is the signal; the specific percentages are noise-prone.
- Whether a retried request can land on a different model than the one requested is not ruled out. The relay logs both
model=(what the client sent) andserved=(what the server reported), so it can be checked — evidence either way is welcome. - Windows launchers only; the relay itself is cross-platform.
- It cannot fix a genuinely exhausted quota, an expired login, or a broken network. Those are different errors and pass through unchanged.
MIT. Fork it, vendor it, ship it inside your own tooling.
中文说明
这是什么
一个本地重试中继,让 「Selected model is at capacity. Please try a different model.」 不再打断你的工作。
不是反代站、不是共享账号、不是中间人。它是 127.0.0.1 上的一个单文件、纯标准库 Python 脚本,用 Codex 自己发出的 OAuth token 转发到官方端点。从 config.toml 删掉一行就回到直连。
安装
下载下面的 codex-overload-fix-1.0.0.zip,解压后:
powershell -ExecutionPolicy Bypass -File scripts\install.ps1安装脚本会找到 Python(3.9+,无依赖)、注册隐藏启动器和看门狗、并打印你要粘贴的 config.toml 片段。不需要管理员权限,不弹控制台窗口。
然后在 %USERPROFILE%\.codex\config.toml 里设置 provider:
model_provider = "openai-retry"
[model_providers.openai-retry]
name = "OpenAI (retry)"
base_url = "http://127.0.0.1:8787"
wire_api = "responses"
requires_openai_auth = true
stream_max_retries = 20
request_max_retries = 10重启 Codex。用 scripts\uninstall.ps1 卸载。
想用 git pull 跟进更新的话,就用 git clone:
git clone https://github.com/NewBeeM4n/codex-overload-fix.git为什么会报这个错
不是额度问题。server_is_overloaded 是HTTP 200 的 SSE 流里的一个 error 事件,所以任何按状态码重试的东西都看不见它。而且拒绝率跟请求体大小相关,跟模型选择无关:
| 请求体 | 数量 | 平均尝试次数 | 最惨 |
|---|---|---|---|
| < 100 KB | 20 | 1.95 | 5 |
| 100–200 KB | 24 | 1.96 | 9 |
| 200–500 KB | 23 | 1.74 | 4 |
| > 500 KB | 4 | 6.75 | 9 |
有一条 799 KB 的请求连续失败 8 次,第 9 次成功。用户全程什么都没看见。
包里面有什么
| 文件 | 作用 |
|---|---|
relay/relay.py |
中继本体 —— 认出 overload,只在还没吐出任何 token 时重试,你取消它就停 |
scripts/install.ps1 / uninstall.ps1 |
隐藏启动器、看门狗、配置片段 |
tools/capture_server.py |
测出你客户端实际发出的请求体大小 |
tools/analyze_log.py |
从 relay.log 汇总尝试次数与体积的关系 |
docs/findings.md |
完整的实测记录 |
校验下载
791c7d32ba9eb9eab50004a9cd722075ca02ee14c202a0c6a3887a28ed45afd4 codex-overload-fix-1.0.0.zip
也作为 .sha256 附件提供。或者让 GitHub 帮你算:
Get-FileHash .\codex-overload-fix-1.0.0.zip -Algorithm SHA256已知局限
- 单机、单账号、样本小。体积相关性是信号,具体百分比当噪声看。
- 没有排除重试后被路由到其他模型的可能性。中继同时记录了
model=(客户端发的)和served=(服务端报的),所以可以核对 —— 欢迎提供任何一方的证据。 - 启动脚本只做了 Windows;中继本身跨平台。
- 治不了额度真正用尽、登录过期、网络不通。那些是不同的错误,会原样透传。
MIT 许可。随便 fork、随便内嵌到你自己工具里。