Repository navigation
fix(#1169): match codex UA case-insensitively so Codex Desktop is detected - #1170
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1170Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1170.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…esktop)
isCodexClient now lowercases the UA before the known-prefix check and registers "codex desktop/" in CODEX_UA_PREFIXES, so Codex Desktop ("Codex Desktop/x.y.z", initial capital) is detected on every codex path. The lenient lowercase-substring fallback stays CASE-SENSITIVE: a case-insensitive fallback would pull non-codex relays with "Codex"-shaped UAs back into codex treatment and re-fork them mid-conversation (#1106).
Fixes #1169
4494e0c to
40f02fd
Compare
[bot] 🏷 Review 结论:原方案不可合并 → 已在 PR 分支直接修正,现在可以合并。 审查过程
发现的问题(拦截原因) 修正(小问题直接在 PR 分支修掉)
效果: 行为变更披露(旧 → 新)
Pre-flight(rebase 后新 head 重跑)
合并是人工操作:#1170 一句话:审查发现原方案(整体大小写不敏感)与 master 上 #1106 钉死的边界冲突(CodeXchange 回归测试失败),已改为「已知前缀大小写不敏感 + 注册 codex desktop/ 前缀,宽松回退保持大小写敏感」,重跑全绿,可以合并。 |
|
Independent review (second pass, on top of the ework bot's): Design — approve, and it is strictly better than the issue's suggested one-liner. Registering Completeness — verified. Evidence — re-verified locally. Rebased onto current master Note for the record: the flipped assertions ( Ready to merge (human). |
[bot] 🏷 收到第二轮独立审查,结论与我一致。补充一个交叉验证:我 rebase 的基线(53c584e)之后,master 新增的提交(release v0.1.139、#1163/#1115、#1172、#1149)与本 PR 的 5 个文件( 关于 flipped assertions 的备注也同意: 合并由人工执行(human-only):#1170 一句话:第二轮独立审查通过,新增 master 提交与本 PR 文件零重叠、无需改动,等待人工合并。 |
What changed
isCodexClient(src/codex-compact.ts) now matchesCODEX_UA_PREFIXEScase-insensitively (UA lowercased once before the prefix check), and"codex desktop/"is registered as a known prefix. The lenientcodexsubstring fallback stays case-sensitive. Tests: two assertions that had pinned the old behavior are updated, plus a regression test for the exactCodex Desktop/0.155.0-alpha.9UA from the issue and a boundary pin (CodeXchange/1.0→ not codex, #1106).Why
Codex Desktop sends
User-Agent: Codex Desktop/x.y.z…with an initial capital. The old code missed it entirely, so none of the codex paths engaged:BILI_CODEX_COMPACT=interceptfell through to native compact, no host-usage exemption, no codex window clamp. This contradicts #645's own goal — "a new client variant must not silently fall out of detection".Review revision (rebased onto current master): the original version of this PR made the entire match case-insensitive, including the lenient substring fallback. Re-running pre-flight on current master surfaced a semantic conflict: commit a5d9173 (merged after this PR's base) pins in
tests/responses-instructions-drift.test.tsthat mixed-case "Codex"-shaped UAs (CodeXchange/1.0) must NOT be treated as codex — a case-insensitive fallback would pull non-codex relays with "Codex"-shaped UAs back into the instructions fingerprint and re-fork them mid-conversation, exactly what #1106 removes. The fix is therefore narrowed to its root cause: register the Codex Desktop variant in the known-prefix table (the designed extension point) and make prefix matching casing-tolerant; the catch-all stays strict.Behavior change (disclosed)
codexanywhere, or starting withcodex_cli_rs//codex_exec/, matched.Codex Desktop/…,Codex_CLI_RS/…,CODEX_EXEC/…, etc. are now recognized; the lenient lowercase-substring fallback is unchanged.CodeXchange) are still NOT treated as codex — preserving the Responses instructions fingerprint should be an allowlist (codex/claude only), not a default — generic relay clients fork on every system-prompt change #1106 boundary pinned intests/responses-instructions-drift.test.ts.src/server.tscompaction_trigger dispatch, forge gate, compact pre-gate, compression target;src/codex-models.ts:84window clamp;src/session-id.ts:117instructions-fingerprint allowlist (Codex Desktop traffic now gets the persona-splitting fingerprint, consistent with other codex clients).Pre-flight (on rebased head, current master)
npm run typecheck— cleannpm test— 2257 pass / 0 fail / 2 skipped (gated e2e); includes the previously conflicting Responses instructions fingerprint should be an allowlist (codex/claude only), not a default — generic relay clients fork on every system-prompt change #1106 test, now greennpm run build— OKFixes #1169