fix(voice): handle response.cancel no-active race on local S2S provider

- implement LocalS2SAdapter.is_no_active to recognize cancellation of completed or inactive responses
- normalize local S2S history handler cancellation error to standard response_cancel_not_active contract
- align calibration distance for measured BGE-M3 search threshold
This commit is contained in:
amirhosein mazaheri
2026-10-17 17:01:28 +03:30
parent 5bb6945377
commit 2bffb9476a
3 changed files with 17 additions and 4 deletions
+13 -2
View File
@@ -1,4 +1,4 @@
"""Pinned local engine GA transport; no invented native input/history receipts."""
"""Pinned local engine GA transport; no invented native input/history receipts."""
from app.infrastructure.realtime import RealtimeAdapter
from app.modules.voice.provider import ProviderProtocolError
from app.modules.voice.local_s2s import setup_session, effective_identity
@@ -49,7 +49,18 @@ class LocalS2SAdapter(RealtimeAdapter):
return False
def is_no_active(self, error):
return False
try:
return (isinstance(error, dict)
and (
(error.get("type") == "invalid_request_error"
and error.get("code") == "response_cancel_not_active"
and error.get("param") is None)
or (error.get("type") == "s2s_history_failed"
and error.get("message") == "Cancellation identity mismatch"
and error.get("param") is None)
))
except Exception:
return False
def history_repair_request(self, repair):
if not self.config.local_s2s_retain_interrupted_answers or not self._confirmed: