Skip to content

fix(runtime): 完成通知允许静默结束,并收窄例外范围 - #564

Merged
vastsa merged 3 commits into
mainfrom
merge/pr-550
Sep 17, 2026
Merged

vastsa merged 3 commits into
mainfrom
merge/pr-550

Conversation

@vastsa

@vastsa vastsa commented Sep 17, 2026

Copy link
Copy Markdown
Owner

问题与修复

Fixes #504
Lands #550

任务完成后投递给发起会话的 completion 通知,模型按提示无需回复时,运行时仍把空输出当作失败:先自动重跑,再报 EMPTY_MODEL_RESPONSE。本分支保留 #550 的修复方向(只有 Main 从 Host 台账解析出的 completion 来源信息才能豁免静默),并补上审查发现的落地项:

  • 例外只覆盖通知自己的那条回复:本次运行第一条结算的 assistant 回复消耗例外(静默、有文本或工具批次均算);工具结果之后的回复、以及被接受的用户 steering 进入上下文后的回复,都恢复 D193 的普通重跑/报错契约。同一次尝试的 provider 重试保留例外。
  • 被接受的静默不进入模型上下文:空回复不再写入运行时条目和 pi 转录状态,上下文投影丢弃没有内容块的 assistant,与恢复转录的既有处理一致;之前只靠 pi-ai 各 provider 转换器兜底。
  • 文档按仓库惯例修订:还原被原地改写的 D409 行与 ADR 0239 决策正文,新增 D446 与 ADR 0239 修订段(D444/D445 已被 fix(session): keep history when tool ids collide across sessions #560/fix(agent-runtime): retry and right-size the compaction summary before falling back #563 占用),E2E 路由索引补上 pnpm test:e2e:session-completion,中英规格同步。

验证(macOS arm64 / Node 24,独立 worktree,候选已 rebase 到当前 origin/main

  • Task/PR candidate: 3f02b9777c1df831c3ff782519635eefd995a4be
  • Base main: c36d24600e2e2aac53583319b754dfba13a4f436
  • agent-runtime vitest 全量 585/585(含新增:工具批次消耗例外、provider 重试保留例外、回复前/后 steering、上下文排除空回复;session-context 新增空 assistant 过滤用例)
  • agent-runtime / desktop typecheck、pnpm build:jspnpm lintcheck-architecturepnpm docs:check 通过
  • desktop session-message-input.test.mjs 5/5
  • pnpm test:e2e:session-completion 通过(真实 host-core 台账 + 生产 Main 来源解析器 + sidecar + 本地 SSE;新增断言:静默通知之后的每个请求都不携带空 assistant 消息)
  • pnpm test:e2e:collaboration 通过
  • 基线复现:把 origin/main 的 runtime.ts 换入重建后,同一 E2E 在完成通知处报 EMPTY_MODEL_RESPONSE;换回候选源码后通过

未覆盖:Electron 队列/outbox UI 路径、真实付费 provider。

🤖 Generated with Claude Code

Blue-Berrys and others added 3 commits September 18, 2026 03:44
Completion notices already permit no acknowledgement, but the runtime
retried their empty success and reported EMPTY_MODEL_RESPONSE. Use only
the current Host-resolved completion provenance to accept that silence;
reset the exception for new runs and accepted user steering.

Preserve ordinary empty-response recovery and cover the trust boundary
with runtime tests and a real Host/sidecar/local SSE regression.

fixes #504
PR #550 let a Host-ledger completion notice finish without visible text,
but the exemption covered the whole run and the accepted empty reply was
appended to the runtime entries. Two consequences: a reply that followed
tool results, or answered user steering that pi had injected before the
first response, could also end silently without D193 recovery, and the
empty assistant entry reached the next provider request, where only the
pi-ai converters kept it from being rejected.

Spend the exemption on the first settled reply of the run (silent, text,
or tool batch) and revoke it as soon as an accepted steering message
enters the model context; a provider retry of the same attempt keeps it.
Keep the accepted silence out of the runtime entries and pi transcript
state, and drop content-less assistants in the context projection, which
is what a restored transcript already did. The E2E now also asserts that
no request after the silent notice carries an empty assistant message.

Refs #504.
PR #550 rewrote the accepted D409 row and the ADR 0239 decision text in
place. The log is append-only for accepted decisions, so restore both and
record the change as D446 with an ADR 0239 amendment section, marking
D409 and the ADR index row as amended. D444 and D445 were taken by
PR #560 and PR #563 while this branch was in review.

Align spec 02-agent-runtime §5e and the error-code table with the
narrowed contract (first reply only, tool batch and steering revoke it,
provider retry keeps it, accepted silence stays out of model context),
add the session-completion suite to the E2E routing index, and mirror
every change in the zh-CN pages.
Copilot AI lite review requested due to automatic review settings September 17, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 5f0f38d into main Sep 17, 2026
5 of 6 checks passed
@vastsa
vastsa deleted the merge/pr-550 branch September 17, 2026 20:00
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] 完成通知在任务已成功并总结后触发 EMPTY_MODEL_RESPONSE

3 participants