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.
This commit is contained in:
Bohdan Triapitsyn
2026-07-12 01:23:22 +03:00
committed by GitHub
parent 82c039117a
commit bb45164ae8
73 changed files with 3330 additions and 29 deletions
+37
View File
@@ -293,6 +293,10 @@ export const dict: Record<I18nKey, string> = {
'sessions.scheduledTasks.editor.prompt.placeholder': '未完了のタスクを要約し次のアクションを提案',
'sessions.scheduledTasks.editor.enabled.aria': 'タスクを有効にする',
'sessions.scheduledTasks.editor.enabled.label': '有効',
'sessions.scheduledTasks.editor.goal.label': 'ゴールとして実行',
'sessions.scheduledTasks.editor.goal.aria': 'このタスクをエージェントが完了まで追求するゴールとして実行します',
'sessions.scheduledTasks.editor.goal.budgetLabel': 'トークン予算',
'sessions.scheduledTasks.editor.goal.budgetAria': 'ゴールをトークン予算で制限します',
'sessions.scheduledTasks.editor.actions.closeAria': '閉じる',
'sessions.scheduledTasks.editor.actions.cancel': 'キャンセル',
'sessions.scheduledTasks.editor.actions.save': '保存',
@@ -1407,6 +1411,39 @@ export const dict: Record<I18nKey, string> = {
'header.actions.terminalPanelWithShortcut': 'ターミナルパネル({shortcut})',
'chat.recap.aria': 'セッションの要約',
'chat.recap.label': '要約:',
'chat.goal.dialog.titleCreate': 'セッションゴールを設定',
'chat.goal.dialog.titleManage': 'セッションゴール',
'chat.goal.dialog.objectiveLabel': '目標',
'chat.goal.dialog.objectivePlaceholder': 'エージェントが到達して検証すべき最終状態を記述してください…',
'chat.goal.dialog.budgetLabel': 'トークン予算',
'chat.goal.status.active': '進行中',
'chat.goal.status.evaluating': '評価中…',
'chat.goal.status.paused': '一時停止',
'chat.goal.status.blocked': 'ブロック',
'chat.goal.status.budgetLimited': '予算上限に到達',
'chat.goal.status.complete': '完了',
'chat.goal.usage.tokens': '{used} トークン',
'chat.goal.usage.tokensWithBudget': '{used}/{budget} トークン',
'chat.goal.usage.turns': '継続 {turns} 回',
'chat.goal.action.pause': '一時停止',
'chat.goal.action.resume': '再開',
'chat.goal.action.markComplete': '完了にする',
'chat.goal.action.clear': 'ゴールを削除',
'chat.goal.action.cancel': 'キャンセル',
'chat.goal.action.save': 'ゴールを保存',
'chat.goal.action.start': 'ゴールを開始',
'chat.goal.toast.actionFailed': 'ゴールの更新に失敗しました',
'chat.goal.row.aria': 'セッションゴール — 詳細を開く',
'chat.goal.button.createAria': 'セッションゴールを設定',
'chat.goal.button.manageAria': 'セッションゴールを管理',
'chat.goal.button.armAria': '次のメッセージでゴールを開始',
'chat.goal.counter.aria': 'ゴール目標の文字数上限',
'chat.goal.button.disarmAria': 'ゴール待機中 — タップで解除',
'chat.goal.button.cancelAria': 'ゴール実行中 — タップでキャンセル',
'chat.goal.cancelDialog.title': 'このゴールをキャンセルしますか?',
'chat.goal.cancelDialog.description': 'エージェントはこのゴールへの自動作業を停止します。',
'chat.goal.cancelDialog.keep': 'ゴールを維持',
'chat.goal.cancelDialog.confirm': 'ゴールをキャンセル',
'chat.suggestion.applyAria': '提案されたメッセージを使用',
'chat.suggestion.dismissAria': '提案を閉じる',
'header.actions.toggleTerminalPanelAria': 'ターミナルパネルの切り替え',