Repository navigation
feat: opt-in gpt-5.x reasoning-truncation guard - #740
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-740Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr740.tgz
npm install -g packageThis comment is automatically updated on each push. |
[bot] 🏷 Review of PR #740 (reasoning-guard) Diff cleanliness — ✅ clean. Single commit, 4 files, +909/−0, purely additive (new module + config passthrough + one Pre-flight — ✅ all green (ran locally on branch head
The It only engages when
I'd rather not widen the gate myself — engaging alongside the rewriter silently drops the #371 retry and the compress-nudge channel for those turns (a functional regression for the compression loop). My recommendation for v1: keep the gate, but (a) document that enabling Non-blocking findings:
Code quality is good overall — pure-function extraction, Verdict: hold for your call on the applicability question above ( 中文摘要:diff 干净、typecheck/test/build 全绿;但发现一个关键适用性问题——guard 以 |
|
"reasoningGuard": { "enabled": true, "models": ["gpt-5", "gpt-6"], 这个配置是不是和三级是冲突的? 另外这个是临时配置? |
[bot] 🏷 两个问题分开答,先给结论。 Q1:和三级压缩配置冲突吗?结论:数据上不冲突(不会互相覆盖、不会打架),但有两处真实的耦合/不一致,你感觉到的"冲突"应该主要来自第一处。 ① 功能耦合(这是真·依赖,也是上一轮我提的那个阻塞点) 也就是说:guard 能不能跑,取决于 compress 那套配置里的 ② 作用域机制不一致 + 命名撞车
我的建议(Q1):
Q2:是临时配置吗?要不要加专门的临时字段?我的判断:它是"workaround 形态",但耐久性一半一半,所以现在不建议新开一个"临时配置"层。
我的建议(Q2): 保持它作为正常、默认关的顶层选项(PR 现状)。不为单个特性新增"临时配置"层。 只有当你预期后面还有第二、第三个同类 workaround 时,再抽一个轻量 一句话串起来reasoningGuard 最稳的心智定位是:一等公民的 opt-in workaround,故意放在三级级联之外(按模型族而非 route/模型 scope),易变部分已隔离在具名字段里。这样 Q1 的不一致和 Q2 的临时性就一致地解决了;唯一还需要你拍板的是①那条功能门控(共存 vs 二选一)。 要不要我现在就把 (a) 字段改名 + 文档说明 +(Q1①) 的启动告警补到分支上?还是你先定①的方向,我再动手? |
Port codexcomp/cpa-plugin detect->continue->fold fix for gpt-5.x 518n-2 reasoning truncation into bili as a single-process, default-off core module (src/reasoning-guard.ts). When enabled and a Responses/SSE stream from a matched model terminates with reasoning_tokens on the 518n-2 lattice, bili replays the round's reasoning items (+encrypted_content) with a continuation nudge up to N rounds, folds them into one response, and reports true summed usage. Otherwise the existing pipeline is untouched.
Community telemetry (gpt-6-astra reasoning-token distribution) confirms the same 518n-2 truncation lattice on GPT-6. Broaden DEFAULT_MODELS from the specific 5.5/5.6 releases to family prefixes [gpt-5, gpt-6] so both lines are covered out of the box; detection stays strict (exact lattice + encrypted content), so breadth adds no false-positive action.
…#739) The inner models prefix list overlapped with three-level scoping and could neuter a deeper-level enable (an inherited global models list would silently filter out a model-level enable). Scoping is now expressed purely by where the block sits in the global/provider/model tree; the strict detection signature (exact lattice hit + encrypted_content + no tool calls) limits actual action. A legacy models key in an existing config is ignored, not fatal.
86510a4 to
5f60153
Compare
Fixes #739
Ports the codexcomp / cpa-plugin detect → continue → fold fix for the gpt-5.x
518n−2reasoning-truncation problem into bili as a single-process, default-off core module — no extra proxy process stacked on top of bili.What it does
New module
src/reasoning-guard.ts. The guard takes over the stream only when all of these hold:reasoningGuard.enabled: true(default off)/responses, streaming)gpt-5.5,gpt-5.6; empty list = all models)reasoning_tokenshits the lattice(rt+2) % 518 === 0 && rt >= 516(i.e. 516, 1034, 1552, …)On engage it buffers the round, replays that round's reasoning items (including
encrypted_content) with aphase:"commentary"Continue thinking...nudge up tomaxContinuerounds, folds everything into one reconstructed terminal response, and reports true summed usage undermetadata.proxy_billed_usage(plusmetadata.proxy_rounds). Reasoning is streamed live (Codex TTFB); non-reasoning items are buffered and flushed on a clean stop. If any gate fails — or the round is clean — the existing pipeline runs untouched, so there is zero behavior change when disabled.Design notes
SseSinkinterface decouples the fold fromnode:http.ServerResponseso it is unit-testable.Files
src/reasoning-guard.ts(new) — guard + live-fold state machinesrc/config.ts—reasoningGuardoption (ProxyOptions+FileConfig+loadOptionspassthrough)src/server.ts—forward()proxy-mode hook + config hot-reloadtests/reasoning-guard.test.ts(new) — 12 tests (pure functions + 2 local-server SSE integration tests of the fold)Pre-flight
npm run typecheck✓npm test✓ (1441 pass / 0 fail / 2 skipped e2e-gated)npm run build✓