Skip to content

修复总结截断:思考模型不下发 max_tokens,截断 fail-loud - #65

Merged
zj1123581321 merged 3 commits into
mainfrom
card/summary-trunc
Aug 24, 2026
Merged

修复总结截断:思考模型不下发 max_tokens,截断 fail-loud#65
zj1123581321 merged 3 commits into
mainfrom
card/summary-trunc

Conversation

@zj1123581321

Copy link
Copy Markdown
Collaborator

背景

2026-08-24 的总结篇幅预算治理(68e2107)给总结调用下发了 max_tokens = hard_cap × 1.5,但生产总结模型是思考模型,reasoning token 计入 completion 预算。实测复现(同网关同模型):max_tokens=5046 中 reasoning 占 4431(88%),正文被 finish_reason=length 切断;最重一例正文仅 193 字且断句中间,但通过全部字符层校验落盘,页面显示为「内容高度浓缩」。

根因:字符级预算与 token 级上限量纲混淆;思考 token 是调用方不可控的预算竞争者,截断失败模式对全部四层防线不可见。

修复

  • 止血reasoning_effort != "disabled"(思考形态)不下发 max_tokens,靠 prompt 篇幅目标 + 字符级后验压缩重试
  • 截断 fail-loud:下发 max_tokens 且 completion_tokens >= max_tokens 判定截断 → 压缩语义重试一次 → 仍截断则 SummaryStatus.FAILED,截断文本永不落盘
  • usage 透出LLMResponse.usage 从 usage_context 桥接快照挂载(peek 不破坏既有 pop 审计契约)
  • 页面:浓缩提示仅在 summary_state == 'generated' 时显示
  • 运维scripts/scan_truncated_summaries.py 扫 audit.db 疑似截断调用(受害重生成另行安排)

Task-Id: VideoTranscriptAPI-20260824-04;llm-compat 侧正路依赖见 zlxlabs/llm-compat#25

测试

  • 全量 uv run pytest tests/llm tests/unit -q 绿(exit 0,进度线无 F/E)
  • 红验:test_transcript_condensation_hint.py 在 base 上红(失败态仍显示浓缩提示)

reasoning_effort 非 disabled 时不发 max_tokens,避免思考 token 挤占正文预算;
下发 max_tokens 且 completion_tokens 打满时判定截断并重试,仍截断则 FAILED 不落盘。
LLMResponse 透出 usage 供截断判定;失败态页面不再显示「内容高度浓缩」提示。

Co-authored-by: Cursor <cursoragent@cursor.com>
Agent-Executor: cursor
Agent-Model: composer-2.5
Agent-Effort: unknown
Dispatch-Id: dlg-20260824-133558-fd0c2f
Task-Id: VideoTranscriptAPI-20260824-04
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Required Gate v2 — 状态面板

当前状态:pass · 可合并

当前裁决:code_pass / primary_pass

Gate 历史(v1;来源为持久化 gate_terminal 制品)

Run Attempt Head 状态 收件人动作
32738880237 1 5fd47ca skipped 无需动作(主审未跑,绿≠过审)
32741454436 1 7ed9f74 skipped 无需动作(主审未跑,绿≠过审)
32745767860 1 7ed9f74 pass 可合并
32745803093 1 a77286d pass 可合并

历史行按 run_id + run_attempt 去重并只增不删;删除本评论后可由 gate_terminal 制品重建。

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

⚙️ Review ledger state(机器状态记录,非评审结论)

这是 review ledger 的机器状态记录,不代表评审结论,通常无需任何操作。

机器状态明细
  • Commit: a77286d543f2c7188c131ec17d1a6121922966ef
  • Round: 4
  • Status / findings: pass / 1
  • Reviewer: codex-sub
  • Comparison: new_head; persistent/resolved/new = 0/0/1

完整数据保存在 codex-review-ledger-v2 artifact;此 sticky comment 仅保存 v2 epoch 的跨 rerun 连续游标。

zj1123581321 and others added 2 commits August 24, 2026 22:52
Agent-Executor: codex
Agent-Model: gpt-5.6-luna
Agent-Effort: xhigh
Dispatch-Id: dlg-20260824-143605-1d04d3
Task-Id: VideoTranscriptAPI-20260824-05
压缩重试 completion_tokens 打满 max_tokens 时不再整段 FAILED,丢弃截断重试
文本并保留 working_text,与重试异常路径对称;首答截断 fail-loud 语义不变。

Co-authored-by: Cursor <cursoragent@cursor.com>
Agent-Executor: cursor
Agent-Model: composer-2.5
Agent-Effort: unknown
Dispatch-Id: dlg-20260824-152412-1d898a
Task-Id: VideoTranscriptAPI-20260824-04
@zj1123581321

Copy link
Copy Markdown
Collaborator Author

R1 verdict(codex 正向全量):pass-with-backlog,0 P1/P2 — docs/sessions/260824-summary-trunc/reviews/summary-truncation-r1-verdict.md
R2 verdict(grok 对抗视角):pass-with-backlog,0 P1、2 P2 — docs/sessions/260824-summary-trunc/reviews/summary-truncation-r2-verdict.md
R2 P2#1(压缩重试截断连坐 FAILED)已修(a77286d,增量审过);P2#2 与 P3 记 backlog。
OCR 前置:reviewed,3 条均 ≤P2 分诊。

@zj1123581321
zj1123581321 marked this pull request as ready for review August 24, 2026 15:35
@zj1123581321
zj1123581321 merged commit a870f56 into main Aug 24, 2026
10 checks passed
@zj1123581321
zj1123581321 deleted the card/summary-trunc branch August 24, 2026 15:42
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.

1 participant