fix(voice): decouple cancellation race handling from model and voice

This commit is contained in:
amirhosein mazaheri
2026-10-14 12:04:08 +03:30
parent 15558fd850
commit 1f7c2bd195
8 changed files with 134 additions and 23 deletions
@@ -0,0 +1,61 @@
# Isolated OpenAI Mini candidate and rollback
The original rag-api container is retained, with its image, environment and mounts.
The candidate rag-api-mini uses the separately built rag-api-model-switch:20261014
image and changes only OPENAI_REALTIME_MODEL to gpt-realtime-2.1-mini via
docker-compose.voice-candidate.yml. Local .env remains the original profile.
The old image is also tagged rag-api-rollback:20261014.
Both API instances share the database and startup reconciliation, so never run
both simultaneously, even on different ports. Switching ends current voice sessions;
start a fresh session. Worker, frontend, documents and database are not replaced.
Container rollback preserves code/configuration, not a database snapshot or live
session. Do not run compose down, container rm, or image pruning for this workflow.
Build the candidate without replacing the current container:
```powershell
docker build -t rag-api-model-switch:20261014 .
```
Switch after tests pass (if startup/readiness fails, stop the candidate and start
rag-api immediately):
```powershell
docker stop rag-api
docker compose -f docker-compose.yml -f docker-compose.voice-candidate.yml up -d --no-deps --no-build api_candidate
Invoke-RestMethod http://localhost:8080/health/ready
```
Rollback using the original container, without any rebuild:
```powershell
docker stop rag-api-mini
docker start rag-api
Invoke-RestMethod http://localhost:8080/health/ready
```
Switch back to the existing candidate:
```powershell
docker stop rag-api
docker start rag-api-mini
```
Do not run the ordinary compose api up while the candidate owns port 8080.
Readiness is not provider or Persian quality acceptance. Actual microphone tests
must cover interruption during response and search, repeated questions, source
reports and long-session behavior. Unknown provider failures remain failures.
## Verification checkpoint
Before the code fix, expanded regressions reproduced 15 failures (40 passed).
Afterward, 343 focused provider-free cases passed. Adding wrong-cancellation-intent
coverage then passed all 57 context-sync cases, including two additional cases.
The candidate API reports ready; frontend responds HTTP 200. Runtime inspection
confirmed 2.1-mini/Marin, speed 1.30, 2048 output tokens, gpt-transcribe and low
reasoning. No provider generation or real microphone acceptance was performed.
Original container ID remains
65c9fa765c150467bde2d6336b09fb46d5ffe451d1117eb1ab93a7bacff1037d,
with its original image and configuration; it is stopped, not removed.
The unrelated pre-existing .gitignore edit is excluded from this change.