Skip to content

fix(#2308): preflight Responses summary extraction excludes reasoning items/parts - #2310

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-07_preflight-responses-reasoning
Oct 7, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-07_preflight-responses-reasoning

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2308

What changed

extractSummaryText() (src/preflight.ts) — the Responses branch now reads only assistant message bodies: an explicitly-declared item type must be message and an explicitly-declared part type must be output_text; reasoning-family items/parts (reasoning/reasoning_text, summary_text, …) no longer leak into the extracted summary. Typeless shapes stay accepted for gateways that omit type, and the top-level output_text compat form is untouched. Both entry shapes are fixed by the one shared helper: the JSON branch (requestSummary) and the SSE terminals (response.completed / response.output_item.done).

Behavior change (the fix itself, disclosed per policy):

No config surface added. No wire/session/persistence changes. Both compression modes unaffected (preflight is the server-side backstop in both; plugin-mode agents own their own summaries and never hit this extractor).

Tests

New suite tests/preflight-responses-reasoning-extract.test.ts pins: JSON/SSE × completed/item.done with reasoning present, reasoning-only → "", valid-delta fallback when completed carries only reasoning, typeless gateway compat, top-level output_text compat, multi-message concatenation with explicit non-message types excluded. The issue's minimal repro (expected 79 chars, got 1529) now returns exactly the 79-char final body.

Local (targeted): typecheck clean; all 149 preflight-* suites pass; launcher suite 281/281. Full regression left to CI.

In-passing minor fix (separate commit, unrelated to #2308)

src/launcher.ts: dropped the leading export from internal-only codexRewriteInsertionIndex — the CI unused-exports job was red on master before this PR (verified against a clean checkout). One word, zero behavior change, makes this PR's CI green.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-07_preflight-responses-reasoning (52d4454)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2443-pr.2310.f8e6683

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2310.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2310 review 结论 — 可合(mergeable)

独立核验(不只信描述,全部实际跑过):

  • in-passing 小修的声称成立:scripts/check-unused-exports.mjs 在干净 master(74cf524,即本 PR base)上跑 → 恰好 1 个失败:INTERNAL_ONLY src/launcher.ts: codexRewriteInsertionIndex;在 PR 分支上跑 → clean。GitHub API 复核:master head 的 unused-exports job 确实 failure、PR head 上 success。该符号零外部引用(git grep 与门禁脚本自身的全文计数一致),去 export 零行为变化。
  • 本地定向验证(PR 分支 worktree):typecheck clean;21 个 preflight-* + 5 个 launcher-* 测试文件共 476 tests → 475 pass / 1 skip / 0 fail。
  • CI:PR head 全部 24 个 job completed、零失败(此前 in_progress 的 test 矩阵也已全绿)。
  • 代码审查:修复打在根因上——单一共享 helper extractSummaryText() 覆盖全部入口形态(JSON 分支 requestSummary + SSE response.completed / response.output_item.done);按声明类型白名单(item 必须 message、part 必须 output_text),typeless 网关形态保持旧行为,top-level output_text compat 未动;reasoning-only → "" → 进入既有 unusable-summary 诊断链([Bug] Codex 额度中断后恢复长会话,preflight SSE 摘要为空并持续 502 #726/fix: recover preflight from empty SSE summaries + dead-end cooldown (#726) #727)而非存成摘要。SSE 有效 delta 回退与 error/incomplete 帧路径未变且有测试钉住。无 as any/@ts-ignore,diff 每行都与目的相关。

结构化七问:

  1. 是什么问题:Responses preflight 提取摘要时不辨 item/part 声明类型、把所有 .text 无差别拼接,模型思考(reasoning_text)混进了被持久化的摘要——真实案例 12,341 字思考混入 7,054 字摘要;最小复现期望 79 字符、实得 1529。
  2. 什么原因导致的:提取器(extractSummaryText)没有"声明类型"概念,把任何 content[].text 都当摘要正文,思考类 item/part 随之被持久化。
  3. 怎么修复的:在提取源头按声明类型白名单过滤,而不是在保存后清洗——显式声明必须为 message/output_text 才取文本,未声明(typeless)形态维持兼容;一个 helper 同时修好两个入口形态,不留旁路。
  4. 是否有回归问题:逐项审过触碰路径的既有行为——非 Responses 协议分支未动;SSE delta 累积回退保持(测试钉住 "deltas win");error/incomplete/failed 帧处理保持;top-level output_text compat 保持;typeless 网关形态保持;launcher 导出移除零外部引用。唯一的行为变化是有意且已在 PR 正文披露:reasoning-only 响应从"存成摘要"变为 ""+诊断链——即修复本身。全量 CI 24/24 绿。
  5. 是否破坏缓存:否。前缀字节、session 状态格式、重试/去重键均未变;摘要更干净(不再含思考污染)对后续压缩质量严格有利。
  6. 是否改了设计方向:否。保持在既有提取器设计内,无架构/边界/数据流转向。
  7. 是否引入了新的配置:无。

协调提示(不阻塞本 PR):#2311(preflight Responses 姊妹修复,#2309)与 #2306(launcher preset-table 重构)仍 open 且触碰相同文件区域——若任一先合并,请先 rebase #2310 并重跑 preflight/launcher 套件再合。

判定:可合——方向正确(根因修复)、测试有牙、diff 干净、CI 全绿。合并请人工操作:#2310

@ranxianglei
ranxianglei merged commit 0beb2e1 into master Oct 7, 2026
24 checks passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.103-master.0beb2e1 (rolling master tag).

npm install -g billion-context@0.0.103-master.0beb2e1  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

@ranxianglei
ranxianglei deleted the 2026-10-07_preflight-responses-reasoning branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] preflight:Responses 摘要抽取混入 reasoning_text,JSON 和 SSE 终态均受影响

1 participant