fix: voice answers no longer wait behind chat answers; late chat answers are dropped
- The voice worker writes voice and chat replies in separate lanes (one of each at a time), so a chat answer being written never holds up a voice answer. Tests: a voice reply finishes while a chat reply is still running; replies of one kind stay one at a time. - A chat answer arriving 5 minutes or more after it was asked is not posted, checked when it arrives. - Specs: the lanes, and that Strata needs --parallel 2 for both lanes' LLM calls to run at once until the app starts Strata itself (M5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,9 @@ class VoiceWorker:
|
||||
self.tick_s = tick_s
|
||||
self.history = history # jarvis.memory.history.HistoryStore or None
|
||||
self.brain = brain
|
||||
self.brain_lock = asyncio.Lock() # one reply at a time
|
||||
# One reply at a time per lane: voice answers never wait behind a chat answer (conversation.md:
|
||||
# with an "answer everything" chat channel the LLM takes two or more requests at once).
|
||||
self.brain_lanes = {"voice": asyncio.Lock(), "chat": asyncio.Lock()}
|
||||
self.chat_timeout_s = chat_timeout_s
|
||||
# chat_action ids are unique across connections and worker runs, so a late answer from an
|
||||
# earlier connection (or an earlier worker) never completes a newer action.
|
||||
@@ -545,7 +547,7 @@ class Session:
|
||||
async def _reply_inner(self, rid: str, user: str, text: str, via: str, speak: bool) -> None:
|
||||
w = self.worker
|
||||
channel = self.voice_channel
|
||||
async with w.brain_lock:
|
||||
async with w.brain_lanes[via]:
|
||||
if self.closed:
|
||||
return
|
||||
now = time.time()
|
||||
|
||||
Reference in New Issue
Block a user