Files
openchamber/packages/docs/content/docs/zh-cn/session-goals.mdx
T
Bohdan Triapitsyn bb45164ae8 feat: session goals - server-driven goal loop with independent small-model audit (#2148)
Arm the target button in the composer and the next prompt becomes a goal:
the server keeps the session working toward it (idle tick -> small-model
audit -> continuation) until the objective is verifiably complete, blocked,
or out of budget — even with the UI closed.

Server (packages/web/server/lib/session-goal):
- event-driven loop on the global SSE hub; goal state lives in
  session.metadata.openchamber.goal (merge-safe patches, stale-write guard
  by goal id), so it survives restarts and syncs to every client for free
- the small-model audit (objective + last assistant turn only, language
  pinned to the objective) is the sole termination authority; blocked needs
  3 consecutive verdicts, audit outages tolerate one unaudited continuation
  then stop the goal as resumable-blocked
- hard stops: optional token budget, auto-continuation cap (Resume grants a
  fresh allowance), turn errors; user abort pauses the goal instead of
  blocking it, and resuming over an aborted tail nudges immediately
- token accounting as a snapshot of the latest turn (input + cache.read +
  output), goal-relative via a creation baseline and segmented across
  compactions; a compaction summary skips the audit and continues
- continuations reuse the session's own provider/model/agent/variant

UI:
- three-mode target button (arm / disarm / manage dialog), informational
  goal strip with inline pause/resume and an Evaluating indicator, sidebar
  state glyph, objective length counter (2000-char server clamp),
  read-only completed goals
- goal entry points: composer (sessions and drafts), start-new-session-
  from-answer dialog, plan implement dialog (plan content becomes the
  objective), scheduled tasks (Run as goal + budget)
- Settings -> Chat -> Goal: feature toggle + default token budget with
  three-layer parity (web server, client persistence, VS Code bridge);
  VS Code renders goal state but hides the entry points (the loop runs in
  the web server only)

Notifications: per-turn "ready" notifications are suppressed while a goal
is active; settling sends one final notification (desktop, web-push, APNs
generic titles with the session name as body) honoring the completion
toggle. Error/question/permission notifications are untouched.

Docs: user guide (session-goals) in all 9 locales + sidebar entry,
scheduled-tasks cross-reference, server module DOCUMENTATION.md.
2026-07-12 01:23:22 +03:00

74 lines
4.8 KiB
Plaintext

---
title: 会话目标
description: 将一条提示词变成目标,代理会自动持续朝它推进。
---
# 会话目标
目标把一条提示词变成终点线。你不用在每次回复后催促代理"继续",只需设置一次目标 — OpenChamber 会自动让会话朝目标推进,并在每一轮之后用独立的审核模型检查进度。即使你不在电脑前,它也会继续运行。
## 启动目标
1. 按下输入框中的靶心按钮。它亮起 — 目标模式已就绪。
2. 输入提示词并发送。这条消息就成为目标内容。
在现有会话和新会话草稿中都一样:启用靶心,写下第一条消息,发送 — 新会话一开始就带着已激活的目标。
### 启动目标的更多方式
- **从代理的回复**:在 "Start new session from this answer" 对话框中勾选**作为目标运行** — 回复将作为任务移交,新会话会把它执行到完成(与 **Create worktree** 结合可获得隔离的运行环境)。
- **从计划**:在新会话或 worktree 中实施已保存的计划时,在对话框中勾选**作为目标运行**。目标会携带计划内容,因此审核会以实际计划为准判断进度。
- **按计划**:在[计划任务](/scheduled-tasks/)上勾选**作为目标运行**,让周期性运行把提示词推进到完成。
## 写一个自包含的目标
进度审核模型只能看到你的目标和代理的最新回复 — 看不到聊天历史。因此,请把目标消息写得让一个不了解对话上下文的人也能明白完成状态是什么样子。
- 好的写法:"为导出模块添加测试,并让整个测试套件通过。"
- 不太好的写法:"修一下" 或 "按那个思路继续。"
对于小的上下文跟进,不需要目标 — 发一条普通消息就行。
## 工作原理
当代理停下且会话安静片刻后,OpenChamber 会:
1. 让一个小而便宜的模型将最新一轮与目标对照审核:继续、完成,还是卡住了?
2. 如果判定是"继续",就发送续跑提示词,代理重新开始工作。
3. 如果目标已被可验证地达成,目标即完成,你会收到通知。
4. 如果代理真的卡住了(需要你的介入),目标会以"已阻塞"停止 — 但只有在审核连续三次这样判定之后,所以一次小挫折绝不会终结目标。
还有硬性安全限制:可选的令牌预算、自动续跑次数上限,以及轮次出错时停止。如果会话上下文在工作途中被压缩,目标会照常继续 — 撞上上下文窗口本身就证明工作还没完成。
### 停止与恢复
- **停止按钮**会中断正在运行的轮次并暂停目标 — 你明确的"停"永远优先于循环。
- 条带上的**暂停**从另一个方向做同样的事:暂停目标并停止正在运行的轮次。
- 暂停期间正常聊天即可 — 循环不会打扰。
- **继续**重新启动循环:在空闲会话上,续跑提示词会立即发出;如果代理恰好在工作,循环会在它下一次停顿时静静接上。
## 查看与管理
- 输入框上方的条带显示目标的最新进度备注、状态和令牌用量,并内置暂停/继续按钮。当代理已停止而目标仍激活时,条带会显示旋转的**评估中…** — 那是静默窗口和审核正在运行。
- 靶心按钮在目标运行时保持点亮(蓝色),完成时变绿,阻塞或预算耗尽时变红。按下它可打开目标对话框:编辑目标或预算,或移除目标。已完成的目标为只读 — 先移除,再启动新目标。
- 在会话侧边栏中,会话日期旁会出现一个小靶心,颜色对应目标状态。
## 通知
目标激活期间,每轮的"代理就绪"通知会被抑制 — 它们只会重复循环自己的续跑。目标尘埃落定时(完成、阻塞或达到预算),你会收到一条最终通知,出现在桌面并作为移动推送。它遵循同一个"完成时通知"设置;权限请求、提问和错误通知全程照常工作。
## 令牌预算
在 **设置 → 聊天 → 目标** 中可以为新目标设置默认令牌预算。目标达到预算时会以"已达预算"停止而不再消耗 — 你可以提高预算并从目标对话框中恢复。
## 注意事项
- 目标循环运行在 OpenChamber 服务器中,而不是浏览器标签页里。关掉标签页、锁上手机 — 代理继续工作,目标尘埃落定时你会收到通知。服务器(桌面应用或 `openchamber` 进程)必须保持运行。
- 目标使用会话自身的提供商和模型,包括审核调用 — 数据不会流向你未在使用的提供商。
- 每个会话同时只能有一个目标。
## 相关
- [计划任务](/scheduled-tasks/) — 按计划运行提示词;在那里启用"作为目标运行",让计划运行将提示词推进到完成
- [通知](/notifications/) — 如何得知目标已完成