From 04c403e1d04f599ecaeebb22b904d39bf60f573c Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Thu, 27 Aug 2026 07:41:47 +0000 Subject: [PATCH] Fix tagged ref character context --- dumas_h3_longvideos.py | 5 +++-- tests/test_dumas_h3_longvideos.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dumas_h3_longvideos.py b/dumas_h3_longvideos.py index 0cf3871..6fb9fd7 100644 --- a/dumas_h3_longvideos.py +++ b/dumas_h3_longvideos.py @@ -4226,10 +4226,11 @@ def _slot_refs_for_text(text, ref_slots): for slot_number in picture_tags(text): if not (1 <= slot_number <= len(ref_slots or [])): continue - ref = ref_slots[slot_number - 1] + raw = ref_slots[slot_number - 1] + ref = _reference_slot(raw, slot_number) if _reference_image(ref) is None: continue - refs.append((slot_number, _reference_slot(ref, slot_number))) + refs.append((slot_number, ref)) return refs diff --git a/tests/test_dumas_h3_longvideos.py b/tests/test_dumas_h3_longvideos.py index a19cf0c..de5f524 100644 --- a/tests/test_dumas_h3_longvideos.py +++ b/tests/test_dumas_h3_longvideos.py @@ -301,6 +301,19 @@ class DumasH3LongVideosHelperTests(unittest.TestCase): self.assertIn("Persistent wardrobe/style for Mara: red jacket.", context) self.assertIn("Location context for Hangar: wet concrete floor.", context) + def test_reference_context_matches_tagged_character_without_name_in_text(self): + refs = [ + {"kind": "character", "image": "img1", "name": "Mara", "description": "silver hair", "wardrobe": "red jacket"}, + ] + + context = self.module._reference_context_for_text( + "[Generation 1] walks into the room.", + refs, + ) + + self.assertIn("Persistent appearance for Mara: silver hair.", context) + self.assertIn("Persistent wardrobe/style for Mara: red jacket.", context) + def test_reference_character_memory_uses_character_wardrobe_only(self): refs = [ {"kind": "character", "image": "img1", "name": "Mara", "wardrobe": "red jacket, black boots"},