* Resolve the memory session context (index snapshot + optional hot block) * for the current session segment. * * Computed lazily on the first stream for each model. The first pass is * index-only so final tool policy can strip memory without paying hot-set * tokenization cost; if mem
(
modelString: string,
options?: { includeHotMemories?: boolean }
)
| 5537 | * empty/partial context for the whole segment. |
| 5538 | */ |
| 5539 | private async resolveMemoryContext( |
| 5540 | modelString: string, |
| 5541 | options?: { includeHotMemories?: boolean } |
| 5542 | ): Promise<MemorySessionContext | undefined> { |
| 5543 | assert(modelString.length > 0, "resolveMemoryContext requires a model string"); |
| 5544 | const includeHotMemories = options?.includeHotMemories !== false; |
| 5545 | const cached = this.memoryContextByModelString.get(modelString); |
| 5546 | if (cached && (cached.includesHotMemories || !includeHotMemories)) { |
| 5547 | return cached.context ?? undefined; |
| 5548 | } |
| 5549 | |
| 5550 | // Guard for test mocks that may not implement buildMemorySessionContext. |
| 5551 | const context = |
| 5552 | typeof this.aiService.buildMemorySessionContext === "function" |
| 5553 | ? await this.aiService.buildMemorySessionContext(this.workspaceId, modelString, { |
| 5554 | includeHotMemories, |
| 5555 | }) |
| 5556 | : null; |
| 5557 | this.memoryContextByModelString.set(modelString, { |
| 5558 | context, |
| 5559 | includesHotMemories: includeHotMemories, |
| 5560 | }); |
| 5561 | return context ?? undefined; |
| 5562 | } |
| 5563 | |
| 5564 | /** |
| 5565 | * Get post-compaction attachments if they should be injected this turn. |
no test coverage detected