You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
compaction_trigger requests pass through preflight/clamp before compact detection — mutated payload, upstream 400 loop #333
changed the title [-]compaction_trigger requests pass through preflight/clamp before compact detection — mutated payload, relay 400 loop[/-][+]compaction_trigger requests pass through preflight/clamp before compact detection — mutated payload, upstream 400 loop[/+]on Aug 29, 2026
Activity
ranxianglei commentedon Aug 29, 2026
[bot] 收到,正在处理。
初步定位:E2 拦截/门控逻辑在 PR #325 的分支
2026-08-28_codex-compact-intercept上(尚未合入 master),而 preflight 溢出压缩与载荷重建在src/server.ts主管线中先于 compact 检测执行。我会把 compaction 检测前置到 preflight/窗口钳制之前,按 issue 里的三路分发实现:修完后在 #325 分支上追加提交并验证(typecheck / test / build),进展会同步到这里。
[-]compaction_trigger requests pass through preflight/clamp before compact detection — mutated payload, relay 400 loop[/-][+]compaction_trigger requests pass through preflight/clamp before compact detection — mutated payload, upstream 400 loop[/+]ranxianglei commentedon Aug 29, 2026
[bot] 已修复,PR: #335
修复方式(按 issue 里的三路分发方向实现)
检测前置到 per-session 管线顶部(
runPrepare()/preflight 之前),对原始解析后的 body 判定isCodexClient && 最后一个 input item === compaction_trigger,然后三路分发:prepareResponses(transform + 现有伪造逻辑)→ 本地返回伪造的 2 帧 SSE,不碰上游prepared=null透传路径,同 fix: stitched-stream usage double-count after compress re-request (adapter-anthropic >0 guard) #300 hop-marker),不 preflight、不重建、不钳制窗口,也不作为副作用折叠 session state改动
src/codex-compact.ts:安全阀拆成codexCompactGatePre(session, limit)(limit>0、稳态 <90% 窗口、有 active block —— 全部是 transform 之前就可判定的条件)+codexCompactGate = transformOk && gatePre(语义与原来完全一致)src/server.ts管线:前置检测 + 三路分发;未拦截时打日志说明原因(BILI_CODEX_COMPACT=pass/gate preconditions not met/transform/forge failed)src/server.tsprepareResponsesCompact(endpoint 形态):门控前置条件移到processTurn之前检查 —— 不被拦截的 compact 请求不再作为副作用变更 session state(线上行为不变:仍是原始 body 透传)回归测试(4 个新 e2e)
关键:现有 e2e 用 10k 窗口 + ~7700 tok 会话,preflight 从不触发,正好漏掉本 bug。新测试用超窗载荷(14 条消息 ≈15.4k tok > 10k 窗口,即旧顺序触发 preflight 的条件):
processTurn被跳过(无 state 变更)4 个测试在旧代码上全部失败(stash 掉 server.ts 改动验证过),修复后通过。
Pre-flight
npm run typecheck干净npm test761/761 通过npm run build干净两个范围外说明
2026-08-28_codex-compact-intercept(PR feat: intercept + forge codex native compaction when ACP is healthy (#321 PR-E2) #325,E2 拦截伪造本体)。feat: intercept + forge codex native compaction when ACP is healthy (#321 PR-E2) #325 先合、或两个一起合。x-codex-beta-features: remote_compaction_v2头剥离(buildForwardTarget里对所有 codex 请求生效)保持原样未动 —— 那是既有行为且有独立的聚合器拒绝理由。但如果 pass 模式透传到要求该 beta 头的后端(如真 OpenAI)发现 native compaction 需要保留它,可以后续单独处理。fix: forward over-window payload when preflight is exhausted (ranxian…