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,4 +1,5 @@
|
||||
"""Validated backend-only Phase 1 runtime deadlines and finite transport limits."""
|
||||
from typing import Literal
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
@@ -25,7 +26,8 @@ class RuntimeSettings(BaseSettings):
|
||||
# Detected uncommitted speech bytes; excludes silence outside VAD intervals.
|
||||
max_input_buffer_bytes: int = Field(default=3072000, ge=3072000, le=3072000)
|
||||
speech_stop_timeout_seconds: float = Field(default=65, ge=65, le=65, allow_inf_nan=False)
|
||||
max_output_backlog_bytes: int = Field(default=1440000, gt=0, le=1440000)
|
||||
output_capacity_profile: Literal['standard', 'openai-repair'] = 'standard'
|
||||
max_output_backlog_bytes: int = Field(default=1440000, gt=0, le=5760000)
|
||||
output_credit_window_bytes: int = Field(default=72000, ge=48, le=72000)
|
||||
max_control_messages: int = Field(default=64, ge=2, le=64)
|
||||
max_control_bytes: int = Field(default=262144, ge=2048, le=262144)
|
||||
@@ -36,6 +38,26 @@ class RuntimeSettings(BaseSettings):
|
||||
max_intents: int = Field(default=256, gt=0, le=256)
|
||||
max_events: int = Field(default=4096, gt=0, le=4096)
|
||||
max_tool_calls: int = Field(default=256, gt=0, le=256)
|
||||
diagnostic_trace_enabled: int = Field(default=0, ge=0, le=1)
|
||||
|
||||
@classmethod
|
||||
def for_provider(cls, provider):
|
||||
if provider not in ('openai', 'gemini'):
|
||||
raise ValueError('Unsupported voice provider')
|
||||
return cls(output_capacity_profile='openai-repair' if provider == 'openai' else 'standard')
|
||||
|
||||
@model_validator(mode='before')
|
||||
@classmethod
|
||||
def capacity_default(cls, values):
|
||||
if (isinstance(values, dict) and values.get('output_capacity_profile') == 'openai-repair'
|
||||
and 'max_output_backlog_bytes' not in values):
|
||||
values = dict(values, max_output_backlog_bytes=5760000)
|
||||
return values
|
||||
|
||||
@property
|
||||
def output_slab_limit(self):
|
||||
# Up to 600 full slabs plus one partial slab for each of 64 references.
|
||||
return 664 if self.output_capacity_profile == 'openai-repair' else 512
|
||||
|
||||
@property
|
||||
def cancellation_timeout_seconds(self):
|
||||
@@ -62,6 +84,8 @@ class RuntimeSettings(BaseSettings):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def compatible(self):
|
||||
if self.output_capacity_profile == 'standard' and self.max_output_backlog_bytes > 1440000:
|
||||
raise ValueError('Larger output reservoir requires the OpenAI repair profile')
|
||||
seconds_bytes = int(self.max_queued_audio_seconds * 48000)
|
||||
if seconds_bytes % 2 or seconds_bytes < self.max_binary_message_bytes:
|
||||
raise ValueError("Queued audio duration must hold an aligned PCM message")
|
||||
|
||||
Reference in New Issue
Block a user