zai-org / zai-org/feedback

[Bug] Stop Hook 三问题:payload 缺 last_assistant_message、additionalContext 渲染为占屏 assistant 消息、block 输出顶掉主对话

Open
#353 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

提交前确认 · Pre-submission checklist
  • 我已搜索过现有 issue,确认这不是重复
  • 我已阅读 CONTRIBUTING.md
问题类别 · Category

对话 / Agent 交互 · Agent chat

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

严重程度 · Severity

影响体验 · Major(功能可用但体验受损,Stop 钩子最终被迫禁用)

复现频率 · Reproducibility

必现 · Always

问题描述 · Description

Stop 钩子在 ZCode 下存在三个相关问题,叠加后果是 Stop 钩子完全不可用(只能 enabled: false):

  1. payload 缺 last_assistant_message 字段(或字段名与 Claude Code 不一致)
  2. additionalContext 被渲染为独立 assistant 消息,占用主对话消息位
  3. block 可见输出顶掉主对话内容,与 Claude Code 的 block 语义不一致
复现步骤 · Steps to reproduce
  1. ~/.zcode/cli/config.jsonhooks.events 注册 Stop 钩子(powershell.exe -File 调用 .ps1,timeoutMs 30000)
  2. 钩子按 Claude Code 的 payload 语义读取 stdin JSON 的 last_assistant_message,按关键词决定放行或 block(mnemon 0.2.3 的 stop.ps1,CC 生态工具的 Windows 版)
  3. 每轮回复结束观察:payload 中该字段为空/不存在 → 放行逻辑永不命中 → block 每轮触发(实测同一轮回复连续触发 3 次)
  4. 改用 additionalContext 注入替代 block → 注入文本在会话流中以 role=assistant 独立消息渲染,占用主窗口一个消息位(用户视角:正在阅读的主对话被顶掉)
  5. 对照:UserPromptSubmit 钩子的 additionalContext 以 system-reminder 嵌在用户消息内部,不占消息位
期望表现 · Expected behavior
  1. Stop payload schema 与 Claude Code 对齐(stop_hook_activelast_assistant_message 等标准字段),或至少提供两家的字段对照文档
  2. Stop 的 additionalContext 改为嵌入式渲染(system-reminder 或可折叠形式),与 UserPromptSubmit 行为一致,或提供配置开关
  3. block 的 reason 作为模型侧反馈(不渲染或可折叠),不打断用户正在阅读的主对话
实际表现 · Actual behavior

问题一:所有依赖 payload 内容做条件判断的社区 Stop 钩子,在 ZCode 下全部退化为"每轮必拦"。

问题二:Stop 注入文本成为占屏 assistant 消息——"有可见提醒"与"不占屏"物理不可兼得。

问题三:Claude Code 中 Stop block 的语义是"阻止本次停止、reason 作为反馈交给模型继续";ZCode 实现下 Stop 的任何可见输出(block 强制续写 / additionalContext 注入)都渲染为占屏消息,用户最终只能禁用钩子。

ZCode 版本 · ZCode version

3.9.1.5853

设备 / 系统 · Device / OS / Browser

Windows 11 · 钩子经 powershell.exe(Windows PowerShell 5.1)调用

截图 / 录屏 / 日志 · Screenshots / Recordings / Logs

同一钩子在 Claude Code(~/.claude/settings.json + stop.sh)下工作正常,问题仅出现在 ZCode 侧。可提供钩子脚本内容、config.json 片段与会话记录协助复现。

建议优先级

问题一(payload 字段对齐)改造成本最低、社区收益最大,建议优先处理。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Stop hook with ~/.zcode/cli/config.json, powershell.exe, and the referenced stop.ps1, then inspect the stdin JSON and session rendering for the three reported behaviors. Compare the Stop payload with Claude Code's fields and compare Stop additionalContext with UserPromptSubmit. Done means the payload and documented field mapping are usable, injected context does not occupy an assistant message, and block feedback preserves the main conversation.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.