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);
|
||||
|
||||
Reference in New Issue
Block a user