修复 API Key app-server 认证重试循环 #205

Merged
kdletters merged 6 commits from codex/issue-187 into master 2026-08-28 15:06:10 +08:00
Member

修复摘要

Close #187

Issue #187 的根因是:API Key/provider-proxy 模式使用隔离 CODEX_HOME,其中没有 ChatGPT auth.json;Codex app-server 默认启动 remote-control 后,会在 desired_state=Unknown 时每约 1 秒重试认证,形成持续的认证日志循环。

本 PR 的最终修复是启动级禁用,而不是单纯屏蔽日志:

  • API Key 和 provider-proxy 会话在启动 Codex app-server 子进程前设置 CODEX_INTERNAL_APP_SERVER_REMOTE_CONTROL_DISABLED=1,使 remote-control 从启动时即处于 desired_state=Disabled
  • 删除此前握手后调用 remoteControl/disable 的方案;真实 smoke 证明该 RPC 在无 ChatGPT 登录态时本身会返回 remote control requires ChatGPT authentication,无法阻止认证循环。
  • 真实 AuthBridge 登录态不设置该变量,保持原有 remote-control 行为。
  • API Key 子进程额外设置 RUST_LOG=warn,仅收敛剩余预期噪音,不承担修复职责。
  • 更新 Unix fake app-server fixture、JSON-RPC 响应 ID 序列和凭据边界回归测试。
  • 同步更新技术方案,明确启动环境变量、认证边界和验证结论。

真实 smoke

使用临时 API Key、隔离 CODEX_HOME 和 Codex 0.150.0-alpha.8

  • 未设置启动变量时:出现 remote control requires ChatGPT authentication,并持续输出 Reloading auth / Reloaded auth
  • 设置 CODEX_INTERNAL_APP_SERVER_REMOTE_CONTROL_DISABLED=1 后:状态为 desired_state=Disabled,5 秒观察窗口内不再出现认证重试循环,仅剩少量启动/退出生命周期日志。
  • --disable remote_control-c features.remote_control=false 未达到同等效果。

验证

  • cargo test --bin genarrative-ai-game-creator-shell codex_app_server:36 passed,1 ignored,0 failed
  • cargo check --bin genarrative-ai-game-creator-shell:通过
  • rustfmt --edition 2021 --check src/agent/codex_app_server.rs:通过
  • npm run ai-game-creator-shell:typecheck:通过
  • npm run check:encoding:通过
  • git diff --check:通过

Windows 本机不会执行 Unix-only fake app-server 分支;相关 fixture 已更新,交由 Linux CI 覆盖。真实 smoke 只验证启动与认证循环,没有执行模型请求。

安全说明:临时 API Key 仅用于本次隔离 smoke,未写入仓库、提交或 PR;测试完成后应立即撤销/轮换该 Key。

## 修复摘要 Close #187 Issue #187 的根因是:API Key/provider-proxy 模式使用隔离 `CODEX_HOME`,其中没有 ChatGPT `auth.json`;Codex app-server 默认启动 remote-control 后,会在 `desired_state=Unknown` 时每约 1 秒重试认证,形成持续的认证日志循环。 本 PR 的最终修复是启动级禁用,而不是单纯屏蔽日志: - API Key 和 provider-proxy 会话在启动 Codex app-server 子进程前设置 `CODEX_INTERNAL_APP_SERVER_REMOTE_CONTROL_DISABLED=1`,使 remote-control 从启动时即处于 `desired_state=Disabled`。 - 删除此前握手后调用 `remoteControl/disable` 的方案;真实 smoke 证明该 RPC 在无 ChatGPT 登录态时本身会返回 `remote control requires ChatGPT authentication`,无法阻止认证循环。 - 真实 AuthBridge 登录态不设置该变量,保持原有 remote-control 行为。 - API Key 子进程额外设置 `RUST_LOG=warn`,仅收敛剩余预期噪音,不承担修复职责。 - 更新 Unix fake app-server fixture、JSON-RPC 响应 ID 序列和凭据边界回归测试。 - 同步更新技术方案,明确启动环境变量、认证边界和验证结论。 ## 真实 smoke 使用临时 API Key、隔离 `CODEX_HOME` 和 Codex `0.150.0-alpha.8`: - 未设置启动变量时:出现 `remote control requires ChatGPT authentication`,并持续输出 `Reloading auth` / `Reloaded auth`。 - 设置 `CODEX_INTERNAL_APP_SERVER_REMOTE_CONTROL_DISABLED=1` 后:状态为 `desired_state=Disabled`,5 秒观察窗口内不再出现认证重试循环,仅剩少量启动/退出生命周期日志。 - `--disable remote_control` 与 `-c features.remote_control=false` 未达到同等效果。 ## 验证 - `cargo test --bin genarrative-ai-game-creator-shell codex_app_server`:36 passed,1 ignored,0 failed - `cargo check --bin genarrative-ai-game-creator-shell`:通过 - `rustfmt --edition 2021 --check src/agent/codex_app_server.rs`:通过 - `npm run ai-game-creator-shell:typecheck`:通过 - `npm run check:encoding`:通过 - `git diff --check`:通过 Windows 本机不会执行 Unix-only fake app-server 分支;相关 fixture 已更新,交由 Linux CI 覆盖。真实 smoke 只验证启动与认证循环,没有执行模型请求。 安全说明:临时 API Key 仅用于本次隔离 smoke,未写入仓库、提交或 PR;测试完成后应立即撤销/轮换该 Key。
suzmii added 1 commit 2026-08-27 18:10:39 +08:00
修复 API Key app-server 认证重试循环
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 3m52s
Project CI / Native shell tests (pull_request) Failing after 9m47s
8f15b83aba
API Key/provider-proxy 握手后主动关闭 remote-control

无 ChatGPT 登录态时将子进程日志级别收敛到 warn

补充 app-server 协议 fixture 回归覆盖与技术方案说明
suzmii added 1 commit 2026-08-27 18:19:50 +08:00
Merge branch 'master' into codex/issue-187
Project CI / Repository checks (pull_request) Successful in 2m35s
Project CI / Frontend tests (pull_request) Successful in 2m54s
Project CI / Backend tests (pull_request) Successful in 5m57s
Project CI / Native shell tests (pull_request) Successful in 14m21s
47676d76be
suzmii added 2 commits 2026-08-27 20:09:40 +08:00
使用 Codex 内部启动环境变量提前禁用 remote-control

删除无效的 remoteControl/disable RPC

更新 fixture、测试和技术文档
Merge remote-tracking branch 'origin/codex/issue-187' into codex/issue-187
Project CI / Repository checks (pull_request) Successful in 3m21s
Project CI / Frontend tests (pull_request) Successful in 3m44s
Project CI / Backend tests (pull_request) Successful in 5m53s
Project CI / Native shell tests (pull_request) Successful in 15m4s
35851a58e6
kdletters added 1 commit 2026-08-27 22:05:13 +08:00
Merge branch 'master' into codex/issue-187
Project CI / Repository checks (pull_request) Successful in 23m0s
Project CI / Backend tests (pull_request) Successful in 17m56s
Project CI / Frontend tests (pull_request) Successful in 19m28s
Project CI / Native shell tests (pull_request) Successful in 30m56s
93c067d16f
suzmii added 1 commit 2026-08-28 09:44:31 +08:00
Merge branch 'master' into codex/issue-187
Project CI / Repository checks (pull_request) Successful in 3m20s
Project CI / Frontend tests (pull_request) Successful in 3m49s
Project CI / Backend tests (pull_request) Successful in 6m52s
Project CI / Native shell tests (pull_request) Successful in 14m50s
1ab97302a1
kdletters merged commit 7d4c47ec0c into master 2026-08-28 15:06:10 +08:00
kdletters deleted branch codex/issue-187 2026-08-28 15:06:10 +08:00
Sign in to join this conversation.