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:
11linear11
2026-10-12 17:57:27 -04:00
parent 9e6864ae2a
commit 111710c47c
33 changed files with 1189 additions and 55 deletions
+62
View File
@@ -55,6 +55,68 @@ async def cleanup(runtime, receive):
await asyncio.gather(receive,return_exceptions=True)
await runtime.close()
def test_close_attempts_transport_when_pump_resists_cancellation():
async def scenario():
wire = FakeGoogleTransport()
aborted = []
wire.transport = SimpleNamespace(abort=lambda: aborted.append(True))
adapter = GeminiLiveAdapter(wire, settings=RuntimeSettings(_env_file=None, send_timeout_seconds=.02))
started, release = asyncio.Event(), asyncio.Event()
async def pump():
started.set()
try:
await release.wait()
except asyncio.CancelledError:
await release.wait()
adapter._pump_task = asyncio.create_task(pump())
await started.wait()
try:
waiter = asyncio.create_task(adapter.close())
await asyncio.sleep(0)
waiter.cancel()
await asyncio.gather(waiter, return_exceptions=True)
for _ in range(2):
with pytest.raises(TimeoutError, match='pump termination'):
await asyncio.wait_for(adapter.close(), .5)
assert wire.closed == 1 and aborted == [True]
assert adapter._inbound_events.empty()
finally:
release.set()
await adapter._pump_task
asyncio.run(scenario())
def test_close_transport_deadline_does_not_wait_for_cancellation_acknowledgement():
async def scenario():
wire = FakeGoogleTransport()
started, release, cancelled = asyncio.Event(), asyncio.Event(), asyncio.Event()
aborted = []
async def close():
wire.closed += 1
started.set()
try:
await release.wait()
except asyncio.CancelledError:
cancelled.set()
await release.wait()
wire.close = close
wire.transport = SimpleNamespace(abort=lambda: aborted.append(True))
adapter = GeminiLiveAdapter(wire, settings=RuntimeSettings(_env_file=None, send_timeout_seconds=.02))
try:
with pytest.raises(TimeoutError, match='transport close'):
await asyncio.wait_for(adapter.close(), .5)
await started.wait()
await cancelled.wait()
assert wire.closed == 1 and aborted == [True]
with pytest.raises(TimeoutError, match='transport close'):
await adapter.close()
assert wire.closed == 1
finally:
release.set()
await asyncio.sleep(0)
asyncio.run(scenario())
@pytest.mark.parametrize('rows,status', [([row()],'ok'),([],'no_evidence')])
def test_native_tool_correlation_canonical_result_and_once_only_continuation(settings,monkeypatch,runner,persisted,rows,status):
service = canonical_service(settings,monkeypatch,rows)