From 9ee27e0792950239580d5713d874a992d10a7e2b Mon Sep 17 00:00:00 2001 From: Shay Date: Thu, 14 May 2026 13:23:21 -0700 Subject: [PATCH] =?UTF-8?q?feat(chat):=20wire=20SentenceAssembler=20into?= =?UTF-8?q?=20chat/runtime=20=E2=80=94=20coherent=20surface=20sentences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor sentence assembly to use SentenceAssembler for coherent sentence generation. --- chat/runtime.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chat/runtime.py b/chat/runtime.py index 246b8f50..f1983568 100644 --- a/chat/runtime.py +++ b/chat/runtime.py @@ -24,6 +24,7 @@ from generate.articulation import ArticulationPlan, realize from generate.dialogue import DialogueRole, classify_dialogue_blade, propose_dialogue from generate.proposition import FrameRegistry, Proposition, propose from generate.stream import generate +from generate.surface import SentenceAssembler, SentencePlan from language_packs import OOVPolicy, load_mounted_packs, load_pack, load_pack_entries from persona.motor import PersonaMotor from session.context import SessionContext @@ -357,11 +358,16 @@ class ChatRuntime: ) self._context.turn += 1 - guarded = self._syntactic_guard(result.tokens) - walk_surface = " ".join(guarded) + # Assemble a coherent sentence from the articulation plan + walk tokens. + sentence_plan: SentencePlan = SentenceAssembler().assemble( + articulation, + result.tokens, + role=dialogue_role, + ) + walk_surface = sentence_plan.surface - # If flagged, suppress walk and fall back to articulation surface. - surface = articulation.surface if flagged else (articulation.surface or walk_surface) + # If identity check flagged the response, fall back to bare articulation surface. + surface = articulation.surface if flagged else walk_surface # Count vault hits that fired this turn (recall_top_k is the ceiling). vault_hits = 3 if self.config.allow_cross_language_recall else 0