From bd13b64959bdf801c0037b61fd16a737b02da320 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 26 Apr 2026 17:40:07 -0400 Subject: [PATCH] chore: remove defensive stale-guest degrade in regenerate.py (T73.3) Phase 2 T44 added a defensive degrade-to-1:1 here when `chat.guest_bot_id` pointed at a deleted bot. T47 fixed the root cause: `bot_reset` cascade-clears the column when the referenced bot is purged (verified by tests/test_reset.py), so the guard was dead code. No corresponding stale-guest test existed in tests/test_regenerate.py to remove. The bot_reset cascade test in tests/test_reset.py already covers the root-cause behavior. --- chat/services/regenerate.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chat/services/regenerate.py b/chat/services/regenerate.py index c432d20..6427092 100644 --- a/chat/services/regenerate.py +++ b/chat/services/regenerate.py @@ -114,13 +114,13 @@ async def regenerate_assistant_turn( # Phase 2: surface the guest (if any) so the prompt assembler and # downstream multi-entity passes see the same shape post_turn does. + # Phase 2 T47 made bot_reset cascade-clear ``chat.guest_bot_id`` when + # the referenced bot is purged (verified by tests/test_reset.py), so + # we trust the column here: it's either a valid bot id or NULL. guest_bot_id = chat.get("guest_bot_id") - guest_bot: dict | None = None - if guest_bot_id is not None: - guest_bot = get_bot(conn, guest_bot_id) - if guest_bot is None: - # Stale guest reference — degrade to single-bot regenerate. - guest_bot_id = None + guest_bot: dict | None = ( + get_bot(conn, guest_bot_id) if guest_bot_id is not None else None + ) # 1. Locate the original assistant_turn event. row = conn.execute(