(workspaceId: string)
| 2690 | } |
| 2691 | |
| 2692 | private createSession(workspaceId: string): AgentSession { |
| 2693 | return new AgentSession({ |
| 2694 | workspaceId, |
| 2695 | config: this.config, |
| 2696 | historyService: this.historyService, |
| 2697 | aiService: this.aiService, |
| 2698 | telemetryService: this.telemetryService, |
| 2699 | initStateManager: this.initStateManager, |
| 2700 | workspaceGoalService: this.workspaceGoalService, |
| 2701 | backgroundProcessManager: this.backgroundProcessManager, |
| 2702 | onCompactionComplete: (metadata) => { |
| 2703 | this.schedulePostCompactionMetadataRefresh(workspaceId); |
| 2704 | // Compaction marks a long session with accumulated learnings: harvest |
| 2705 | // the compacted epoch first, then let Dream sweep/merge the candidates. |
| 2706 | this.memoryConsolidationService?.triggerHarvestThenSweepInBackground(metadata); |
| 2707 | }, |
| 2708 | onIdleCompactionOutcome: (success) => { |
| 2709 | // Reports the *persisted* idle-compaction outcome (success only after the summary |
| 2710 | // is written; failure on post-stream persistence errors). Reporting on actual |
| 2711 | // persistence — not the provider stream-end — keeps the idle loop's failure streak |
| 2712 | // accurate. A persistence failure is not a model error, so modelNotFound is false. |
| 2713 | this.reportIdleCompactionOutcome( |
| 2714 | workspaceId, |
| 2715 | success ? { success: true } : { success: false, modelNotFound: false } |
| 2716 | ); |
| 2717 | }, |
| 2718 | onPostCompactionStateChange: () => { |
| 2719 | this.schedulePostCompactionMetadataRefresh(workspaceId); |
| 2720 | }, |
| 2721 | }); |
| 2722 | } |
| 2723 | |
| 2724 | private attachSessionSubscriptions(workspaceId: string, session: AgentSession): void { |
| 2725 | const chatUnsubscribe = session.onChatEvent((event) => { |
no test coverage detected