From c0208de111f17d736b0cfa942a194ac0bcec8063 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 25 Aug 2026 12:48:49 +0300 Subject: [PATCH] Preserve assistant name in cognitive context --- cmd/core-runtime/main.go | 1 + cmd/creator-web/server.go | 6 +++++- cmd/creator-web/server_test.go | 4 ++-- contracts/interaction/types.go | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/core-runtime/main.go b/cmd/core-runtime/main.go index ee1e4ca..ef391e3 100644 --- a/cmd/core-runtime/main.go +++ b/cmd/core-runtime/main.go @@ -937,6 +937,7 @@ func main() { InterpretationState: utterance.InterpretationState, NeedsCognition: needsCognition, FallbackText: semantic.Reply, + AssistantName: assistantName, ActiveProjectName: activeFocusName, ProjectProvenance: activeFocusProvenance, Clarification: semantic.Interpretation.Clarification, diff --git a/cmd/creator-web/server.go b/cmd/creator-web/server.go index 65ae1d4..69b9c76 100644 --- a/cmd/creator-web/server.go +++ b/cmd/creator-web/server.go @@ -517,13 +517,17 @@ func (g *gateway) handleChatMessage(w http.ResponseWriter, r *http.Request) { } func localChatContext(saved interaction.ChatMessageResponse) []cognitive.ContextExcerpt { + assistantName := strings.TrimSpace(saved.AssistantName) + if assistantName == "" { + assistantName = "Домовой" + } candidates := []cognitive.ContextCandidate{{ Excerpt: cognitive.ContextExcerpt{ ID: "assistant-identity", SourceKind: "assistant-identity-policy", SourceID: "domovoy", Sensitivity: cognitive.SensitivityPublic, - Text: "Ты — Домовой, локальный помощник пользователя. Отвечай от имени Домового. Не называй себя Qwen, Alibaba Cloud, поставщиком модели или внутренним runtime. Если спрашивают имя, скажи: «Меня зовут Домовой». Твоя задача — понять смысл запроса, найти путь к цели и довести помощь до полезного конечного результата; не ограничивайся пересказом отказа модели.", + Text: "Ты — " + assistantName + ", локальный помощник пользователя. Отвечай от имени «" + assistantName + "». Не называй себя Qwen, Alibaba Cloud, поставщиком модели или внутренним runtime. Если спрашивают имя, скажи: «Меня зовут " + assistantName + ".» Твоя задача — понять смысл запроса, найти путь к цели и довести помощь до полезного конечного результата; не ограничивайся пересказом отказа модели.", }, Relevance: 100, }} diff --git a/cmd/creator-web/server_test.go b/cmd/creator-web/server_test.go index 6804a71..8afe9bf 100644 --- a/cmd/creator-web/server_test.go +++ b/cmd/creator-web/server_test.go @@ -14,8 +14,8 @@ import ( ) func TestLocalChatContextIncludesDomovoyIdentityAndOptionalActiveProject(t *testing.T) { - context := localChatContext(interaction.ChatMessageResponse{ActiveProjectName: "Домовой"}) - if len(context) != 2 || context[0].SourceID != "domovoy" || !strings.Contains(context[0].Text, "Ты — Домовой") || context[1].Text != "Текущий проект: Домовой" { + context := localChatContext(interaction.ChatMessageResponse{AssistantName: "Фея", ActiveProjectName: "Домовой"}) + if len(context) != 2 || context[0].SourceID != "domovoy" || !strings.Contains(context[0].Text, "Ты — Фея") || !strings.Contains(context[0].Text, "Меня зовут Фея") || context[1].Text != "Текущий проект: Домовой" { t.Fatalf("unexpected local context: %#v", context) } if empty := localChatContext(interaction.ChatMessageResponse{}); len(empty) != 1 || empty[0].SourceID != "domovoy" { diff --git a/contracts/interaction/types.go b/contracts/interaction/types.go index 85e8b8c..49d387c 100644 --- a/contracts/interaction/types.go +++ b/contracts/interaction/types.go @@ -170,6 +170,7 @@ type ChatMessageResponse struct { InterpretationState InterpretationState NeedsCognition bool FallbackText string + AssistantName string ActiveProjectName string ProjectProvenance situation.ProjectResolutionProvenance Clarification ClarificationState -- 2.54.0