mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
feat: caller context cache invalidation endpoint
- CallerContextService: added invalidateCache(leadId) method - CallerResolutionController: POST /api/caller/invalidate-context endpoint — frontend calls after appointment mutations to bust stale AI context cache Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,13 @@ export class CallerContextService {
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async invalidateCache(leadId: string): Promise<void> {
|
||||||
|
if (!leadId) return;
|
||||||
|
const cacheKey = `${CACHE_KEY_PREFIX}${leadId}`;
|
||||||
|
await this.session.deleteCache(cacheKey).catch(() => {});
|
||||||
|
this.logger.log(`[CALLER-CTX] Cache invalidated for ${leadId}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Fire-and-forget pre-warm — called from caller resolution
|
// Fire-and-forget pre-warm — called from caller resolution
|
||||||
// so the cache is hot when the AI stream fires seconds later.
|
// so the cache is hot when the AI stream fires seconds later.
|
||||||
prewarm(leadId: string, patientId: string, auth: string): void {
|
prewarm(leadId: string, patientId: string, auth: string): void {
|
||||||
|
|||||||
@@ -33,4 +33,13 @@ export class CallerResolutionController {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('invalidate-context')
|
||||||
|
async invalidateContext(@Body('leadId') leadId: string) {
|
||||||
|
if (!leadId) {
|
||||||
|
throw new HttpException('leadId is required', HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
await this.callerContext.invalidateCache(leadId);
|
||||||
|
return { status: 'ok' };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user