From 925ce223a0490e1ddcb8f55e3fb35672763024a4 Mon Sep 17 00:00:00 2001 From: kami Date: Fri, 31 Jul 2026 02:13:40 +0400 Subject: [PATCH] Add a Value slot to dialogue.Slots router.Slots already carries the fact payload; the dialogue copy did not, so a clarifying answer had nowhere to put it. InheritSlots carries it like Key. Reviewer: check the new inherit block does not overwrite a filled value. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01CGeSZxh1DCtRxmFVSYVGvJ --- internal/dialogue/session.go | 4 ++++ internal/dialogue/session_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/internal/dialogue/session.go b/internal/dialogue/session.go index 452d27f..a573c99 100644 --- a/internal/dialogue/session.go +++ b/internal/dialogue/session.go @@ -21,6 +21,7 @@ type Slots struct { Time time.Time HasTime bool Key string + Value string // payload for a fact key, mirrors router.Slots.Value HasKey bool Text string Fn string @@ -104,6 +105,9 @@ func InheritSlots(prev, cur Slots) Slots { out.Key = prev.Key out.HasKey = true } + if out.Value == "" && prev.Value != "" { + out.Value = prev.Value + } if out.Text == "" && prev.Text != "" { out.Text = prev.Text } diff --git a/internal/dialogue/session_test.go b/internal/dialogue/session_test.go index 819efa7..735896d 100644 --- a/internal/dialogue/session_test.go +++ b/internal/dialogue/session_test.go @@ -113,4 +113,14 @@ func TestInheritSlots(t *testing.T) { if inherited6.Text != "какая погода в москве" { t.Error("should inherit text when current is empty") } + + prevValue := Slots{Key: "water", HasKey: true, Value: `"drank"`} + inherited7 := InheritSlots(prevValue, Slots{}) + if inherited7.Value != `"drank"` { + t.Error("should inherit value when current is empty") + } + kept := InheritSlots(prevValue, Slots{Value: "2l"}) + if kept.Value != "2l" { + t.Error("should keep current value") + } }