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()
|
||||
|
||||
@@ -218,7 +218,9 @@ which carry Discord's own time.
|
||||
or when it was said, or who heard it. A final said outside a voice channel is not stored.
|
||||
- Chat messages are stored only as given; the app sends only registered channels.
|
||||
- `reply` asks the brain to answer `user`'s `text`. The worker builds the history context for that
|
||||
user (their scope only) and runs the reply engine on a worker thread, one reply at a time.
|
||||
user (their scope only) and runs the reply engine on a worker thread, one voice reply and one chat
|
||||
reply at a time: the two kinds have separate lanes, so a voice answer never waits behind a chat
|
||||
answer (`app/src/conversation.spec.md`, chat calls).
|
||||
`reply_text` carries the answer (`failed: true` with empty text when the brain gave none). A voice
|
||||
answer (`via: "voice"`) is stored as a `reply` record to the user in the current channel; a chat
|
||||
answer is stored when the app reports the sent message as `chat_message` with `to`. With
|
||||
|
||||
Reference in New Issue
Block a user