From dfecab7c34b389a077855058a99f8ac93c2cda46 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 25 Aug 2026 02:56:00 +0300 Subject: [PATCH] Scope durable assistant memory to principal --- adapters/postgres/interaction_repository.go | 4 ++-- cmd/core-runtime/main.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/postgres/interaction_repository.go b/adapters/postgres/interaction_repository.go index 617e97f..25c7bc9 100644 --- a/adapters/postgres/interaction_repository.go +++ b/adapters/postgres/interaction_repository.go @@ -102,8 +102,8 @@ func (r *InteractionRepository) Utterances(ctx context.Context, id interaction.C // RecentUtterancesForPrincipal provides durable conversational context when a // client starts a fresh conversation instead of carrying the previous ID. -func (r *InteractionRepository) RecentUtterancesForPrincipal(ctx context.Context, actorID identity.ActorID, principalID identity.PrincipalID, limit int) ([]interaction.HumanUtterance, error) { - rows, err := r.pool.Query(ctx, `SELECT utterance_id,conversation_id,actor_id,principal_id,channel,received_at_unix_millis,correlation_id,content,content_ref,speech_act,interpretation_state,corrects_utterance_id FROM interaction.utterances WHERE actor_id=$1 AND principal_id=$2 ORDER BY received_at_unix_millis DESC, utterance_id DESC LIMIT $3`, actorID, principalID, limit) +func (r *InteractionRepository) RecentUtterancesForPrincipal(ctx context.Context, principalID identity.PrincipalID, limit int) ([]interaction.HumanUtterance, error) { + rows, err := r.pool.Query(ctx, `SELECT utterance_id,conversation_id,actor_id,principal_id,channel,received_at_unix_millis,correlation_id,content,content_ref,speech_act,interpretation_state,corrects_utterance_id FROM interaction.utterances WHERE principal_id=$1 ORDER BY received_at_unix_millis DESC, utterance_id DESC LIMIT $2`, principalID, limit) if err != nil { return nil, err } diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index 00e7df2..ee7ca15 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -517,7 +517,7 @@ func main() { // Keep durable user context available even when the web client carries a // conversation ID; a new or rotated conversation must not erase learned // preferences. - recentUserHistory, _ := interactionRepository.RecentUtterancesForPrincipal(r.Context(), session.ActorID, session.PrincipalID, 64) + recentUserHistory, _ := interactionRepository.RecentUtterancesForPrincipal(r.Context(), session.PrincipalID, 64) conversationHistory = append(conversationHistory, recentUserHistory...) if request.ConversationID != "" && interactiondomain.IsRetryRequest(utterance.Content) { if len(conversationHistory) > 0 { -- 2.54.0