feat(voice): support evidence reuse, 120s output capacity, and input ASR coalescing
- Add internal reuse_last_evidence tool for continuing existing topic without repeated retrieval - Expand OpenAI output capacity to 120s / 5,760,000 bytes and add delivery fairness - Coalesce adjacent user ASR transcript deltas to prevent client control queue overflow - Add server-side OPENAI_REALTIME_SPEED configuration and update style to v4 - Add extensive unit and integration regressions for evidence reuse, capacity, and fairness
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Bounded allowlisted voice diagnostics; never log exception text or payloads."""
|
||||
import logging
|
||||
import re
|
||||
from json import JSONDecodeError
|
||||
|
||||
from app.infrastructure.realtime import ProviderProtocolError
|
||||
@@ -113,12 +114,30 @@ EVENT_TYPES = frozenset({
|
||||
})
|
||||
|
||||
NUMERIC_FIELDS = frozenset({
|
||||
"generated_bytes", "queued_bytes", "reserved_bytes", "credit_bytes", "discarded_bytes",
|
||||
"chunk_bytes", "lock_wait_ms", "backlog_bytes", "peak_backlog_bytes",
|
||||
"received_elapsed_ms", "terminal_completed", "terminal_cancelled", "terminal_limited",
|
||||
"authority_ms", "emit_ms", "queued_controls",
|
||||
"cancellation_type_match", "cancellation_code_match", "cancellation_param_match", "cancellation_profile_2_1_shimmer",
|
||||
"transport_limit_bytes", "transport_limit_messages", "occupancy_count", "limit_count", "occupancy_bytes", "limit_bytes", "transport_bytes", "transport_messages",
|
||||
"speech_bytes", "elapsed_ms", "deadline_remaining_ms", "sent_bytes", "played_ms", "pending_commands",
|
||||
"pending_responses", "pending_audio", "pending_tasks", "abort_succeeded", "input_bytes", "http_status",
|
||||
})
|
||||
|
||||
def trace(session_id, stage, *, turn_ref=None, audio_ref=None, **state):
|
||||
"""Opt-in INFO timeline, using application references and numeric counters only."""
|
||||
if not logger.isEnabledFor(logging.INFO):
|
||||
return
|
||||
def reference(value, pattern):
|
||||
return value if isinstance(value, str) and re.fullmatch(pattern, value) else "none"
|
||||
numbers = " ".join(f"{key}={max(-2147483648, min(value, 2147483647))}"
|
||||
for key, value in sorted(state.items())
|
||||
if key in NUMERIC_FIELDS and type(value) is int)
|
||||
logger.info("Voice trace session=%s stage=%s turn=%s audio=%s state=%s",
|
||||
reference(session_id, r"[a-fA-F0-9-]{1,36}"), stage,
|
||||
reference(turn_ref, r"live-turn-[0-9]{1,10}"),
|
||||
reference(audio_ref, r"live-audio-[a-f0-9]{32}"), numbers)
|
||||
|
||||
def diagnostic(session_id, phase, reason, *, event_type=None, exc=None, code=None, **state):
|
||||
# Unknown event types and exception messages can contain private provider data.
|
||||
numbers = " ".join(f"{key}={max(-2147483648, min(value, 2147483647))}"
|
||||
|
||||
Reference in New Issue
Block a user