Add hybrid memory retrieval and escalation history

This commit is contained in:
dahyeon committed 2026-05-18 23:04:34 -07:00
1 parent 1a86bded0b
commit 211de18476
38 files changed
+1602 -37

No files matched your search

+36 -1
View File
@@ -2,6 +2,10 @@ import type { AgentRequest, AgentResponse, ConversationMessage } from '@agent/ty
import type { GarnetClient } from '@common/garnet';
import type { NatsClient } from '@common/nats';
import type { MemoryService } from '../../memory/memory-types.js';
import {
buildLongTermSummary,
shouldRefreshLongTermSummary,
} from '../../memory/long-term-summarizer.js';
import { getContext, getRequestLogger } from '@obs/context';
import type { LlmClient } from '@llm/llm-client';
import type { RoomContextService } from '@room/room-context-service';
@@ -427,12 +431,43 @@ export class OnboardingSkill implements Skill {
return;
}
await this.userMemoryStore.observeTurn(request.userId, derived, response, {
const profile = await this.userMemoryStore.observeTurn(request.userId, derived, response, {
flaggedIssues:
derived.phase.kind === 'nickname-rejected'
? derived.phase.issues.map((issue) => issue.message)
: [],
});
if (!shouldRefreshLongTermSummary(profile)) {
return;
}
void this.refreshLongTermSummary(request, profile);
}
private async refreshLongTermSummary(
request: AgentRequest,
profile: Awaited<ReturnType<UserMemoryStore['observeTurn']>>,
): Promise<void> {
try {
const conversationSummary =
(await this.memoryService?.session.getSummary(
request.chatroomId,
request.userId,
)) ?? null;
const longTermSummary = await buildLongTermSummary(
this.llmClient,
profile,
conversationSummary,
);
await this.userMemoryStore.updateProfile(request.userId, {
longTermSummary,
});
} catch (error) {
getRequestLogger().warn(
{ err: error },
'[OnboardingSkill] Failed to refresh long-term user summary',
);
}
}
private makeTemplateFallbackResponse(