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:
@@ -173,9 +173,11 @@ impl<V: Voice> Conversation<V> {
|
||||
CoreEvent::SpeechStart(h) => self.policy.utterance_open(h.speaker_id),
|
||||
CoreEvent::Chat(m) => self.on_chat(m, now),
|
||||
CoreEvent::ReplyText { id, text, failed } => {
|
||||
if let Some((channel, message, _)) = self.chat_answers.remove(id) {
|
||||
debug_log!("conversation", "chat answer {id} chars={} failed={failed}", text.chars().count());
|
||||
if !failed && !text.trim().is_empty() {
|
||||
if let Some((channel, message, asked)) = self.chat_answers.remove(id) {
|
||||
let late = now >= asked + CHAT_ANSWER_KEPT;
|
||||
debug_log!("conversation", "chat answer {id} chars={} failed={failed} late={late}",
|
||||
text.chars().count());
|
||||
if !failed && !late && !text.trim().is_empty() {
|
||||
self.voice.send_reply(channel, message, text);
|
||||
}
|
||||
}
|
||||
@@ -625,6 +627,15 @@ mod tests {
|
||||
assert_eq!(c.missed().count(), 0, "a chat message never takes the voice turn");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_chat_answer_after_its_keep_time_is_not_posted() {
|
||||
let (mut c, f, t) = chat_conv(CallSettings::default());
|
||||
c.on_event(&chat(CH_WAKE, 5, A, false, "자비스 안녕"), t);
|
||||
let Did::ChatAnswer(id, ..) = f.take().remove(0) else { panic!() };
|
||||
c.on_event(&CoreEvent::ReplyText { id, text: "안녕하세요.".into(), failed: false }, t + CHAT_ANSWER_KEPT);
|
||||
assert!(f.take().is_empty(), "too late: the conversation has moved on");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn end_times_come_from_the_finals_wait() {
|
||||
let (mut c, f, t) = conv(PolicyKind::InOrder, CallMode::WakeWord);
|
||||
|
||||
@@ -132,10 +132,13 @@ never takes the voice turn and never goes through the response policy.
|
||||
- Only a request is answered: a stop in chat ("자비스 멈춰") is not a question and gets no answer.
|
||||
- The brain answers through `reply` with `via: "chat"` and `speak: false`; the answer is posted in the
|
||||
same channel as a Discord reply to the message (so the history records it as an answer to that
|
||||
person), pinging nobody. A failed or empty answer posts nothing. Answers waited for over 5 minutes
|
||||
are forgotten.
|
||||
- Known limit: the worker writes one reply at a time, so a voice answer waits while a chat answer is
|
||||
being written (the LLM's parallel requests for "answer everything" channels are M5/M6 settings).
|
||||
person), pinging nobody. A failed or empty answer posts nothing. An answer that arrives 5 minutes or
|
||||
more after it was asked is not posted.
|
||||
- The worker writes voice and chat answers in separate lanes (`voice_worker.spec.md`), so a voice
|
||||
answer never waits behind a chat answer. For the two to run at the same time the LLM must take two
|
||||
requests at once (`docs/v2/conversation.md`, "LLM 동시 요청 수"): until the app starts Strata itself
|
||||
(M5), Strata is started with `--parallel 2` when some channel answers everything; with
|
||||
`--parallel 1` the two lanes' LLM calls take turns at Strata.
|
||||
|
||||
## The conversation loop
|
||||
|
||||
|
||||
Reference in New Issue
Block a user