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:
committed by
GitHub
parent
82c039117a
commit
bb45164ae8
@@ -0,0 +1,29 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
// Narrow store for the "next message starts a goal" flag. Armed by the
|
||||
// composer target button (works for existing sessions AND session drafts)
|
||||
// and by the run-as-goal flows (fork dialog, plan send); consumed by
|
||||
// sendMessage in session-ui-store, which turns the sent prompt into the
|
||||
// goal objective — unless the arming flow supplied a richer objective
|
||||
// override (e.g. the plan content instead of "Implement this plan: X").
|
||||
interface SessionGoalArmStore {
|
||||
armed: boolean;
|
||||
objectiveOverride: string | null;
|
||||
setArmed: (armed: boolean, objectiveOverride?: string | null) => void;
|
||||
/** Read-and-clear in one step at send time. */
|
||||
consume: () => { armed: boolean; objectiveOverride: string | null };
|
||||
}
|
||||
|
||||
export const useSessionGoalArmStore = create<SessionGoalArmStore>((set, get) => ({
|
||||
armed: false,
|
||||
objectiveOverride: null,
|
||||
setArmed: (armed, objectiveOverride = null) => set({
|
||||
armed,
|
||||
objectiveOverride: armed ? objectiveOverride : null,
|
||||
}),
|
||||
consume: () => {
|
||||
const { armed, objectiveOverride } = get();
|
||||
if (armed) set({ armed: false, objectiveOverride: null });
|
||||
return { armed, objectiveOverride };
|
||||
},
|
||||
}));
|
||||
@@ -574,6 +574,9 @@ interface UIStore {
|
||||
showReasoningTraces: boolean;
|
||||
sessionRecapEnabled: boolean;
|
||||
sessionSuggestionEnabled: boolean;
|
||||
sessionGoalEnabled: boolean;
|
||||
sessionGoalDefaultBudgetEnabled: boolean;
|
||||
sessionGoalDefaultBudget: number;
|
||||
collapsibleThinkingBlocks: boolean;
|
||||
chatRenderMode: ChatRenderMode;
|
||||
activityRenderMode: ActivityRenderMode;
|
||||
@@ -725,6 +728,9 @@ interface UIStore {
|
||||
setShowReasoningTraces: (value: boolean) => void;
|
||||
setSessionRecapEnabled: (value: boolean) => void;
|
||||
setSessionSuggestionEnabled: (value: boolean) => void;
|
||||
setSessionGoalEnabled: (value: boolean) => void;
|
||||
setSessionGoalDefaultBudgetEnabled: (value: boolean) => void;
|
||||
setSessionGoalDefaultBudget: (value: number) => void;
|
||||
setCollapsibleThinkingBlocks: (value: boolean) => void;
|
||||
setChatRenderMode: (value: ChatRenderMode) => void;
|
||||
setActivityRenderMode: (value: ActivityRenderMode) => void;
|
||||
@@ -873,6 +879,9 @@ export const useUIStore = create<UIStore>()(
|
||||
showReasoningTraces: true,
|
||||
sessionRecapEnabled: true,
|
||||
sessionSuggestionEnabled: true,
|
||||
sessionGoalEnabled: true,
|
||||
sessionGoalDefaultBudgetEnabled: false,
|
||||
sessionGoalDefaultBudget: 200_000,
|
||||
collapsibleThinkingBlocks: true,
|
||||
chatRenderMode: 'live',
|
||||
activityRenderMode: 'summary',
|
||||
@@ -1581,6 +1590,18 @@ export const useUIStore = create<UIStore>()(
|
||||
set({ sessionSuggestionEnabled: value });
|
||||
},
|
||||
|
||||
setSessionGoalEnabled: (value) => {
|
||||
set({ sessionGoalEnabled: value });
|
||||
},
|
||||
|
||||
setSessionGoalDefaultBudgetEnabled: (value) => {
|
||||
set({ sessionGoalDefaultBudgetEnabled: value });
|
||||
},
|
||||
|
||||
setSessionGoalDefaultBudget: (value) => {
|
||||
set({ sessionGoalDefaultBudget: value });
|
||||
},
|
||||
|
||||
setCollapsibleThinkingBlocks: (value) => {
|
||||
set({ collapsibleThinkingBlocks: value });
|
||||
},
|
||||
@@ -2276,6 +2297,9 @@ export const useUIStore = create<UIStore>()(
|
||||
showReasoningTraces: state.showReasoningTraces,
|
||||
sessionRecapEnabled: state.sessionRecapEnabled,
|
||||
sessionSuggestionEnabled: state.sessionSuggestionEnabled,
|
||||
sessionGoalEnabled: state.sessionGoalEnabled,
|
||||
sessionGoalDefaultBudgetEnabled: state.sessionGoalDefaultBudgetEnabled,
|
||||
sessionGoalDefaultBudget: state.sessionGoalDefaultBudget,
|
||||
collapsibleThinkingBlocks: state.collapsibleThinkingBlocks,
|
||||
chatRenderMode: state.chatRenderMode,
|
||||
activityRenderMode: state.activityRenderMode,
|
||||
|
||||
Reference in New Issue
Block a user