Repository navigation
fix: 让 GenUI 纯 reasoning 回合触发宿主重试 - #264
Merged
Merged
Conversation
wang-kaopu
marked this pull request as ready for review
October 6, 2026 07:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
承接 #259。
#259 来自 #242 对 reasoning-only 零交付问题的调查。线上曾出现模型连续返回只有 reasoning、没有正文和工具调用的完成结果;
fence-feedback继续发送同类纠正后,还观察到过逐字节相同的 reasoning。后续复现实验没有得到稳定的逐字节重放:
p ≈ 0.66;因此 #259 保留两个宿主恢复方向:
EMPTY_RESPONSE重试机制;本 PR 实现其中的 C,并将改动限制在
dsh-genui。改动
fence-feedback已经通过正式事件记录当前 turn 是否调用过validate_dsh_ui。本 PR 复用这份 session 状态,在llm/streamwaterfall 增加一个很窄的终止结果转换。仅当以下条件同时成立时进行转换:
validate_dsh_ui;purpose;stop结束;reasoningblock;reasoningblock。命中后,将最终:
转换为:
reasoning chunk 本身仍然原样经过 stream,仅改写最终 finish。
这样 AgentLoop 会把该次请求交给宿主现有的:
恢复流程,继续复用宿主已有的有限重试、退避和取消行为。
失败尝试不会提交正式
assistant/message,因此下一次 retry 构造历史时也不会把这次 reasoning-only assistant message 加入请求历史。边界
转换只依赖完成 block 的类型,不读取 reasoning 文本,也不解析其中的
dsh-uispec。以下情况保持原行为:
validate_dsh_ui的 turn;tool-callsfinish;max-tokensfinish;error/abortedfinish;stop,继续由宿主自身的EMPTY_RESPONSE判定处理。fenceFeedback: false继续只控制agent.steer()的同 turn 围栏修正。reasoning-only 零交付仍会进入宿主 retry,因为它属于请求完成结果的恢复。与现有 fence-feedback 的关系
现有
fence-feedback继续处理已经产生正式正文后的 GenUI 交付问题,例如无法渲染的dsh-uifence。本 PR 处理更早的一层:模型请求以 reasoning-only
stop结束、正式正文和工具调用尚未产生的情况。该次请求会在提交assistant/message之前进入宿主 retry,因此无需再等待agent/turn-stopping后发送一次同类纠正。#259 中方案 D 的逐字节重放检测、请求缩短或重建等恢复策略不在本 PR 范围内。现有实验还不足以确定逐字节重放的稳定触发条件,后续需要用户批准并脱敏的真实请求继续验证。
测试
tests/fence-feedback.spec.ts增加覆盖:stop→EMPTY_RESPONSE;max-tokens→ 原样通过;error/aborted→ 原样通过;stop→ 原样通过,由宿主自身处理;validate_dsh_ui的普通 turn → 原样通过;fenceFeedback: false时,同 turn steering 关闭,宿主 reasoning-only retry 仍然生效。同时更新 README、README.zh-CN、CHANGELOG 和配置说明,区分同 turn fence 修正与宿主 request retry。
验证
pnpm exec vitest run tests/fence-feedback.spec.ts pnpm checkAddresses #259 中的方案 C。