feat(coding-agent/hindsight): added per-session HindsightSessionState

- Added `HindsightSessionState` to `AgentSession` and bound hindsight lifecycle hooks to session state.
- Removed global hindsight state/queue handling and replaced it with per-session `HindsightRetainQueue` batching and scoped flushing.
- Reworked recall, reflect, and retain tools to use `session.getHindsightSessionState()` instead of sessionId-based lookup.
- Updated SDK/task/backend/controller flows to pass `session`/`parentHindsightSessionState`, scope `/memory` behavior, and document it in changelog.
This commit is contained in:
can1357
2026-05-03 10:27:06 +02:00
parent 255ef926cf
commit 0e761ef9e0
17 changed files with 711 additions and 694 deletions
@@ -17,6 +17,7 @@ import { SETTINGS_SCHEMA, type SettingPath } from "../config/settings-schema";
import type { CustomTool } from "../extensibility/custom-tools/types";
import { runExtensionCompact, runExtensionSetModel } from "../extensibility/extensions/compact-handler";
import type { Skill } from "../extensibility/skills";
import type { HindsightSessionState } from "../hindsight/state";
import type { LocalProtocolOptions } from "../internal-urls";
import { callTool } from "../mcp/client";
import type { MCPManager } from "../mcp/manager";
@@ -163,6 +164,7 @@ export interface ExecutorOptions {
settings?: Settings;
/** Override local:// protocol options so subagent shares parent's local:// root */
localProtocolOptions?: LocalProtocolOptions;
parentHindsightSessionState?: HindsightSessionState;
}
function parseStringifiedJson(value: unknown): unknown {
@@ -979,6 +981,7 @@ export async function runSubprocess(options: ExecutorOptions): Promise<SingleRes
hasUI: false,
spawns: spawnsEnv,
taskDepth: childDepth,
parentHindsightSessionState: options.parentHindsightSessionState,
parentTaskPrefix: id,
agentId: id,
agentDisplayName: agent.name,