zai-org / zai-org/feedback

[Bug] Goal/子 Goal 跟踪缺陷:顶层 goal 标记 complete 但 completion verifier 连续 FAIL,且子 goal compact 后丢失

Open
#117 2 comments 0 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

问题类别 · Category

对话 / Agent 交互 · Agent chat

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

严重程度 · Severity

P1 — 数据一致性缺陷(goal 状态错误导致用户误判任务完成)

环境 · Environment

  • ZCode 版本:0.15.2
  • 平台:macOS (darwin 25.5.0 arm64)
  • 模型:builtin:bigmodel-coding-plan/GLM-5.2
  • 模式:build / thoughtLevel=max

问题描述 · Description

ZCode 客户端的 Goal/子 Goal 跟踪模式存在三个关联缺陷,导致 goal 状态显示 complete 但实际任务未完成,且子 goal 在会话 compact 后视觉丢失

Bug 1:子 goal 无独立持久化存储,仅作为对话流 <system-reminder> 临时文本注入

子 goal 唯一出现的位置是 ~/.zcode/cli/db/db.sqlitepart 表里 <system-reminder>Continue working toward the active session goal. XXX 文本字段。会话 compact(上下文压缩)后旧 reminder 被丢弃 → 子 goal 视觉上消失。

排查覆盖了所有本地存储,均无子 goal 独立记录:

  • session_target 表只有 1 行(顶层 goal),无 parent/child 字段
  • session_task_link 表 0 行
  • workflow_run / workflow_activity 表 0 行
  • tasks-index.sqlitemeta_json.target 只嵌套顶层 goal
  • IndexedDB / Local Storage / v2/*.json 均无子 goal 文本
Bug 2:顶层 goal complete 与自己的 completion verifier 判定直接矛盾

受影响会话 session_target 记录:顶层 goal 在 13:24 标记 complete。但 ZCode 自己的 completion verifier 在 11 个 <system-reminder> 上判定 9 次 FAIL,最后一次 13:22 明确判定 FAIL("性能门禁 L170 + 其他项未验证")。顶层 goal 在 2 分钟后标记 complete,与自己的 verifier 结论直接矛盾。

verifier 时间线证据(从 partsystem-reminder 提取):

时间 verifier 判定
01:37 FAIL:S0 尚未完成,3 项交付物未实现
02:23 FAIL:SBOM 无 Critical 未达标
02:29 FAIL:验收硬门禁仍有未完成项
02:44 FAIL:L74 GHCR + L101 File 全链路未完成
12:06 FAIL:S1 远未完成,助手自评 PARTIAL
12:42 FAIL:验收硬门禁多项未完成
12:57 FAIL:多项验收硬门禁未关闭
13:14 FAIL:ACL 防枚举 + permitAll 未关闭
13:22 FAIL:性能门禁 L170 + 其他项未验证
13:24 顶层 goal 标记 complete ← 与 2 分钟前的 FAIL 矛盾
Bug 3:compact 后 system-reminder 的 objective 字段经常为空

会话 compact 后的 6 条 system-reminder 里,4 条 objective=(none),说明客户端无法从对话流稳定恢复 active goal —— 这是 Bug 1 的直接后果,也是用户看到"任务丢失"的直接原因。

复现步骤 · Reproduction

  1. 在一个长会话里持续推进一个大型任务(例如"完成s1",涉及 30+ 子项交付物)
  2. 让 ZCode 客户端在多轮对话里动态切换 active session goal(通过 system-reminder 注入新子 goal)
  3. 触发若干次会话 compact(上下文压缩)
  4. 观察:顶层 goal 最终标记 complete,但部分子 goal verifier 判定 FAIL
  5. 观察:UI 里早期子 goal 视觉消失(compact 后 system-reminder 丢弃)

期望行为 · Expected behavior

  • 顶层 goal 标记 complete 前,聚合所有子 goal 最近一次 verifier 判定;任一 FAIL 应阻断或至少标记 partial
  • 子 goal 独立持久化(建议新增 session_subgoal 表:target_id, parent_target_id, objective, status, verifier_result, time_created/updated)
  • compact 后保留 goal 状态栈,不依赖对话流 <system-reminder> 文本隐式恢复

实际行为 · Actual behavior

  • 顶层 goal 标记 complete,与自己的 verifier 判定矛盾
  • 子 goal 在 compact 后视觉丢失,无独立持久化
  • 用户基于错误的 goal complete 状态误以为任务全部完成

修复建议 · Suggestions

  1. 子 goal 独立持久化:新增 session_subgoal 表(target_id, parent_target_id, objective, status, verifier_result, time_created/updated),不要依赖对话流 <system-reminder> 文本
  2. 顶层 goal 状态聚合子 goal verifier:顶层 goal 标记 complete 前必须所有子 goal verifier 最近一次判定为 PASS;任一 FAIL 应阻断或标记 partial
  3. compact 后保留 goal 状态:上下文压缩时显式序列化 active goal 栈
  4. verifier 结果可追溯:每次 verifier 判定落库(run_id, target_id, result, reason, evidence_hash),UI 可展开查看判定依据

附加上下文 · Additional context

  • 完整诊断报告(含数据库查询证据、修复建议)已落盘到本地项目 planning/zcode-goal-bug-report.md
  • 受影响会话:sess_30ddf411-873b-4cd9-8abe-0d7fcc8e28ab
  • 数据源:~/.zcode/cli/db/db.sqlite(session_target / part 表)+ ~/.zcode/v2/tasks-index.sqlite
  • 该问题在本会话消耗约 146M tokens、94 分钟后才发现——如果 goal 状态准确,本可更早识别未完成项

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 with planning/zcode-goal-bug-report.md, then inspect the session_target and part tables in db.sqlite and reproduce the compact/verifier sequence described in the issue. Done means subgoals survive compaction, verifier failures prevent an incorrect complete state, and objective data remains recoverable after compaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite
Domain
backend, database
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.