For agentic workers: 使用
executing-plans按 phase 执行;每个 phase 完成单测和 review 后再进入下一 phase。本计划不依赖 subagent 执行。
Goal: 移除 target_continuation 的 projection-time filter,并通过持久化、MCS-capable 的 goal state reminder 让模型稳定感知 /goal pause|clear|resume 状态变化。普通 /goal set|replace 由真实 user objective 表达,不重复写 state reminder;若 replace 同时造成 paused -> active,仍追加一次 resume reminder。
Architecture: 把 goal continuation 和 goal state change 都作为 append-only provider-visible history 事实。target_continuation 不再靠过滤隐藏;后续 goal pause/clear/resume 通过新的 persisted system reminder source 覆盖旧 continuation 语义。/goal set|replace 依靠真实 user objective 表达新目标;只有从 paused 状态重新变为 active 时才追加 active-again reminder。支持 MCS 的 provider 投成 mid-conversation system,否则 fallback 为 <system-reminder> user message。若 pause 发生在 active regular turn,target DB 与 target_changed 仍在发起该操作的 command mutation 内完成,并且早于 abort;只有 reminder 延迟到 cancelled tool results 全部持久化并进入 live history 后、turn terminal event 前物化。idle 状态变化仍立即物化。
Tech Stack: TypeScript, Vitest, zcode-cli runtime message history, session store hydration, provider request projection.
target_continuation 继续代表 goal continuation,不再被普通请求过滤。目标: 增加一个专门表达 goal 状态变化的 persisted + MCS-capable system reminder source。
Files:
/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/system-reminder/source.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/agent/session-history-hydrator.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/tests/session-history-hydrator.test.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/tests/runtime-provider-request-messages.test.ts 或现有 provider projection 测试文件Checklist:
goal_state_changeSYSTEM_REMINDER_PERSISTED_SOURCESdescriptor("mid_turn_event", "mid_turn_event", true, "sr.goal_state_change")NON_MID_CONVERSATION_SYSTEM_SOURCESmessageHistory.addAttachment("goal_state_change", body)<system-reminder>Suggested Tests:
hydrates persisted goal_state_change synthetic notice as runtime attachmentprojects goal_state_change as mid-conversation system when MCS is supportedfalls back goal_state_change to system-reminder user message when MCS is unsupportedPass Criteria:
goal_state_change 可持久化恢复resume_goal_state、todo_reminder、queued_system_notification目标: 在 /goal pause|clear|resume 发生时追加 model-only synthetic notice,表达最新 goal 状态。set|replace 的目标正文已经是真实 user message,不再重复写 reminder。
Files:
/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/bootstrap/src/app/session-facade.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/bootstrap/src/zcode-protocol/server-operations.ts 如需要补 protocol 边界行为/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/methods/goal-state-reminder.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/methods/turn.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/types.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/internal-methods.ts 如需要新增 runtime helper/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/agent-runtime.ts 如需要声明 helper/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/bootstrap/tests/session-persistence.test.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/bootstrap/tests/zcode-protocol.test.tsReminder 文案建议:
The active session goal is paused. Do not continue pursuing it unless the user resumes or replaces the goal.The session goal is active again and will be pursued.The session goal has been cleared. Do not continue pursuing any previous goal unless the user sets a new goal.Checklist:
persistGoalStateChangeReminder(...)persistSyntheticUserNoticeForSession({ source: "goal_state_change", visibility: "model-only" })messageHistory.addAttachment("goal_state_change", body),保证当前 runtime 立即可见/goal pause 成功时写 pause reminder/goal clear 成功或显式 clear 时写 clear reminder/goal resume 成功时写 resume reminder/goal set 成功时只写真实 user objective,不写 state reminder/goal replace 写真实 user objective;仅当旧目标为 paused、replace 造成 paused -> active 时再写 resume reminderPass Criteria:
目标: 删除普通请求过滤 target_continuation 的特殊逻辑,让 goal continuation 成为稳定 history 事实。
Files:
/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/src/runtime/helpers/runtime-provider-request-messages.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/tests/runtime-tool-loop.test.tsChecklist:
includeTargetContinuationReminders 分支过滤withoutTargetContinuationReminderEntriesincludeTargetContinuationReminders 参数,如无其它用途filters stopped target continuation reminders from following user turnsPass Criteria:
target_continuation目标: 确认 pause/replace/clear 与正在运行的 verifier/continuation 不会串目标。
Files:
/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/tests/runtime-tool-loop.test.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/bootstrap/tests/zcode-protocol.test.tsChecklist:
/goal pause abort active turn 后,cancelled tool results 先于 pause reminder 进入 history 与 session store/goal resume 后,history 有 resume reminder,并触发 continuation loopPass Criteria:
messageHistory 或 synthetic noticemessageHistory.addToolResult(...) 均完成后才物化 remindertarget_changed 已落库,不增加 retry/cursortool_use 已进入 history、tool handler 尚未启动时,仍先合成并持久化 cancelled tool_result,再物化 pause remindertool_result 的 DB 与 live-history 闭合runRegularTurnLoop,并由 loop 外层唯一的 finally 同步关闭后物化 pendingTurnComplete 真正持久化之前时,pause reminder 不丢失,并且仍早于 terminal event 物化target_changed;/goal pause 与 session/stop 在 command mutation 完成后才 aborttool_use 都会得到 cancelled resultsendInput 完成 finalization 后才释放,下一条 desktop/remote host prompt 不能越过 tool result 或 reminderclientMode、deliveryKind、workspace identity 和远控 owner/lease 均无生产代码改动目标: 确认新 synthetic reminder 对 UI、visible content、compact、session context 没有副作用。
Files:
/Users/dev/Desktop/Z/z-code/packages/shared/src/zcode-session-visible-content.ts/Users/dev/Desktop/Z/z-code/packages/ui/src/lib/zcodeChatMessages.ts/Users/dev/Desktop/Z/z-code/packages/shared/test/zcodeSessionVisibleContent.test.ts/Users/dev/Desktop/Z/z-code/packages/ui/test/zcodeSessionProjection.test.ts/Users/dev/Desktop/Z/z-code/apps/zcode-cli/packages/core/tests/session-history-hydrator.test.tsChecklist:
goal_state_change model-only synthetic notice 不显示为普通 user bubbletarget_continuation 改变 assistant 邻接关系Pass Criteria:
target_continuation filter 产生对应 non-incremental diffCommands:
pnpm --dir apps/zcode-cli exec vitest packages/core/tests/runtime-tool-loop.test.ts --run
pnpm --dir apps/zcode-cli exec vitest packages/core/tests/session-history-hydrator.test.ts packages/core/tests/provider-request-messages.test.ts --run
pnpm --dir apps/zcode-cli exec vitest packages/bootstrap/tests/session-persistence.test.ts --run -t 'persists model-only goal state change reminders for goal lifecycle changes|persists replacement goal objective as real user prompt without state reminders'
pnpm --dir apps/zcode-cli exec vitest packages/bootstrap/tests/session-persistence.test.ts --run
pnpm --dir apps/zcode-cli exec vitest packages/bootstrap/tests/zcode-protocol.test.ts --runpnpm --dir apps/zcode-cli exec vitest packages/bootstrap/tests/zcode-protocol.test.ts --run -t 'allows session goal pause to stop a running prompt|pauses an active goal when session stop cancels goal continuation'
/goal pause 与 Generic Stop 两个上游入口。pnpm exec vitest packages/shared/test/zcodeSessionVisibleContent.test.ts --runpnpm exec vitest packages/ui/test/zcodeSessionProjection.test.ts --run
pnpm --filter @zcode/desktop exec wdio run wdio.conf.ts --spec './test/e2e/conversation-session/execution/conversation-session-stop-empty.test.ts'
pnpm --filter @zcode/desktop typecheck:e2epnpm typecheckpnpm --dir apps/zcode-cli typecheckpnpm lint
apps/zcode-cli 全量 lint 仍被既有 max-lines/unused 基线阻断。Manual / Evidence Checks:
system<system-reminder>Done Definition:
target_continuation 不再被 projection filter 删除