Skip to content

refactor(engine): B2 — split the ~240-line voice step into named paths

Maryam Ghorbani requested to merge beta into main

The voice() step had four mutually-exclusive paths (voiceless / group / code-reco / full LLM) plus a grounding guardrail and an early-push block, all inline. Split each into its own helper so voice() is a thin dispatcher. Behavior-preserving.

  • voice(): now only resolves the locale, resets last_facts/voice_grounding_src, and dispatches to one of the paths.
  • extract _voice_voiceless / _voice_code_reco / _voice_llm (one per StopEvent path), _ground_voice (the grounding guardrail + one corrective rewrite), _push_listing (the code-reco early push), and _append_assistant_turn (the history-append that repeated 4x, no-op on blank content).
  • lift _VOICELESS / _CODE_RECO to class-level frozensets (same membership).

Every VoiceEvent path produces identical output; the LLM path still pushes the listing as a task (RTT hidden behind generation), the code-reco path pushes inline.

Verified: test_greeting + test_booking_flow + test_turn_serialization (60) green; wider net (no_results, my_bookings) green.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Merge request reports

Loading