feat: answer calls in the voice channel through the response policy
- conversation.rs: the loop between the core's events and the rest. Finals go through call detection and the response policy; answers are asked of the brain and spoken from the app's queue, an interruption cancels only that answer, a voice stop silences everything, and missed requests are kept without text (last 100). Tested with a fake voice side. - Core: answer(user, text) adopts a playback request the worker speaks under the same id, cancel(id) stops one request, ask_addressed and ask_rank pass the conversation's questions; new SpeakingStopped, Addressed and Ranked events. - Worker client: reply, addressed and rank messages and their results; a reply with no answer, refused or not sent ends its speech as failed. - Voice worker: addressed and rank messages on their own threads, beside a running reply; a spoken reply cancelled while the brain is answering is not spoken. judges.py holds the two short LLM judgements with the heard text fenced as data; eval evals/test_voice_judges.py. - Specs (conversation, discord core, voice worker), docs/llm_contexts.md and the roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,9 +114,37 @@ request first, the answer stops (missed, `interrupted`) and the new request is a
|
||||
running answer first, or does not come in time, the answer goes on and the new request waits. The
|
||||
ranking is dropped when the running answer ends first.
|
||||
|
||||
## The conversation loop
|
||||
|
||||
`app/src/conversation.rs` runs between the core's events and everything else that reads them (every
|
||||
event is passed on unchanged). It talks to the core through a small `Voice` interface (answer, cancel
|
||||
one request, stop all, ask "addressed", ask "rank"), so the glue is tested with a fake.
|
||||
|
||||
- `SpeechStart` opens the speaker's utterance; `SpeakingStopped` marks it ending.
|
||||
- `Final`: a request gets the next id, `ended_at` = arrival minus the final's `wait_ms`, and goes
|
||||
through call detection. Ignore closes the utterance. Stop stops all speech, runs the policy's stop and
|
||||
closes the utterance. Request goes to the policy. Ask sends `addressed` to the brain; a yes becomes the
|
||||
request, a no (or a failed judgement) closes the utterance, and no answer within 5 s counts as no.
|
||||
- Policy actions: `Answer` → `answer(user, text)` (the brain answers and the answer is spoken; when it
|
||||
cannot be queued the answer is done at once); `StopAnswer` → `cancel` of that answer's speech;
|
||||
`Rank { id }` → `rank` with id `k<id>` and the candidates' request ids; `Missed` → a debug log and
|
||||
the missed list (the last 100: speaker, reason, time and length, never the text).
|
||||
- `SpeakEnd` of an answer's speech is that answer's done. The end of a speech the loop already
|
||||
cancelled starts nothing.
|
||||
- `Left` (the bot left the voice channel): the policy's stop, and pending "addressed" questions close
|
||||
their utterances.
|
||||
- A timer wakes the loop at the policy's next deadline or the earliest "addressed" timeout.
|
||||
|
||||
The brain's two judgements are `src/voice_worker/judges.py` (`voice_worker.spec.md`): one short call
|
||||
each to the chat model, the heard text fenced as data. Eval: `evals/test_voice_judges.py`.
|
||||
|
||||
## Tests
|
||||
|
||||
`cargo test` covers call detection (exact and near wake words in Hangul and Latin, a different word
|
||||
two letters away, wake word anywhere, stop with and without a wake word, designated combinations,
|
||||
modes) and every policy rule above with fake times (settling, ordering by end time, busy, queue limit,
|
||||
interruption, ranking tie, ranking timeout, stop dropping the queue).
|
||||
interruption, ranking tie, ranking timeout, stop dropping the queue), and the conversation loop with a
|
||||
fake voice side (answering and queueing, a busy drop recorded without text, voice stop, addressed yes,
|
||||
no and timeout, interruption cancelling the right speech, a ranking deciding, end times from
|
||||
`wait_ms`). `tests/worker_protocol.rs` checks an answer spoken under its id and both judgements against
|
||||
the real Python worker with a fake brain.
|
||||
|
||||
Reference in New Issue
Block a user