Add support for prefix state code

This commit is contained in:
Xin Wang
2026-05-28 09:36:44 +08:00
parent 8c3789754f
commit d94da4b4d1
6 changed files with 181 additions and 10 deletions

View File

@@ -148,6 +148,7 @@ Returned transcripts and assistant text:
```json
{"type": "input.transcript.interim", "text": "What's the"}
{"type": "input.transcript.final", "text": "What's the weather?", "user_id": "...", "timestamp": "..."}
{"type": "response.state", "state": "speaking"}
{"type": "response.text.started"}
{"type": "response.text.delta", "text": "It's "}
{"type": "response.text.delta", "text": "sunny in "}
@@ -163,6 +164,11 @@ the TTS in the pipeline. `response.text.final` fires when the turn ends,
carrying the full concatenated assistant text and an `interrupted` flag
(true when an `input.text` or barge-in cut the turn short).
When `agent.response_state.enabled` is true, an LLM response that starts with
`<state>...</state>` emits the tag body as `response.state` before the
remaining assistant text is streamed and spoken. If the tag is missing or
malformed, the original response text is streamed unchanged.
### Turn detection
User-turn segmentation (VAD thresholds + how long to wait after silence