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
+65 -1
View File
@@ -308,6 +308,14 @@ acknowledgment. Gemini instructions remain unchanged. Voice changes require fres
sessions; candidate voices remain unverified until listening/interruption acceptance.
See [Phase 2 handoff](../guides/openai-persian-delivery-phase2.md).
OpenAI playback-speed configuration is server-only: `OPENAI_REALTIME_SPEED`
(default 1.0, finite range 0.25..1.5) is frozen as
`execution_profile.audio_output_speed` and acknowledged as `audio.output.speed`
before readiness. Changing it requires a new reservation; replay retains the
original snapshot and old/mismatched snapshots fail stream admission. PCM remains
24 kHz and playback credit uses actual provider-generated sample duration.
Gemini profiles and public events are unchanged.
OpenAI Phase 3 freezes optional `execution_profile.reasoning`: null when omitted,
or `{"effort":"low"}` / `{"effort":"medium"}` for the explicitly supported
`gpt-realtime-2.1` and `gpt-realtime-2.1-mini` candidates. Unsupported explicit
@@ -549,6 +557,32 @@ Locators use existing `location.page/section`. DOCX and image use page null, wit
Deduplicate by parent session/turn plus provider call ID and normalized argument hash. Same running call waits; same completed call replays only after fresh eligibility/epoch checks; changed payload conflicts. Cancelled/closed/stale-parent results are not sent back to generate a new answer. No tool request becomes a public REST upload/search endpoint. The MVP persists voice tool_calls independently of deferred text turns/messages/citations. Cancelled work is terminal failed with a cancellation reason and cannot be replayed to resume speech.
### 7.3 Internal continuation tool — `reuse_last_evidence`
The 2026-10-12 Live repair amendment permits an unambiguous same-topic
continuation from the latest successful, delivered evidence bundle in the same
connection. The model supplies exactly `{}`; identity, scope, session and source
selection remain backend-owned. Prior assistant prose is never evidence. New
topics or insufficient evidence require canonical `search_knowledge`; ambiguous
references require clarification. Automatic response chaining remains excluded.
Before reuse and again before delivery/continuation, revalidate the owner/auth
session, active Live session, access epoch, knowledge revision, and each original
document/chunk's ready/active/undeleted/unpurged eligibility. A selection addition
can change knowledge revision without changing access epoch and still invalidates
reuse. Revocation follows the invalid-session contract; it never triggers a
hidden replacement search. Without a reusable bundle, return `no_evidence` with
`warnings:["fresh_search_required"]`, allowing an explicit model search.
Attach evidence to the new turn using real document/chunk identities and
turn-local source labels. Its `sources.tool_call_id` identifies the original
retrieval; reuse creates no `tool_calls` row or embedding/retrieval execution.
Revalidate the original saved result before every delivery. Interrupted/cancelled
tool results are excluded. Fresh search replaces the topic bundle; failure and
session termination clear it. No durable conversation history or cross-session
cache is introduced. New reservations pin `evidence_policy_revision` and the
effective instruction profile; existing reservations are never rewritten.
## 8. Health
H01: 200 `{"status":"ok"}` when the process is alive. H02: 200 `{"status":"ready","ingestion":"available"}` or degraded ingestion marker if worker heartbeat is stale; 503 `{"status":"not_ready"}` for required DB/schema/storage failure. Health responses never disclose connection strings or provider keys. Provider outages surface in relevant business operations, not liveness.
@@ -638,7 +672,37 @@ it. New execution_profile snapshots freeze max_output_tokens and revised OpenAI
instruction revision/digest. Missing/mismatched old snapshots fail existing stream
admission without rewriting reservation identities or profiles. Gemini is unchanged.
This budget includes tool calls and is not a measured PCM-duration guarantee.
All existing reservoir, credit, transport/browser and timeout bounds remain.
Credit, transport/browser and timeout bounds remain. The OpenAI reservoir is
amended below.
### OpenAI output-capacity amendment (2026-10-12)
For the selected OpenAI Live repair profile, aggregate undrained backlog defaults
to **5760000 bytes / 120 seconds**, with a finite 664 packed-slab accounting cap
(600 full slabs plus partial slabs across at most 64 unretired references).
`LIVE_MAX_OUTPUT_BACKLOG_BYTES` may select a smaller aligned bound. Values above
5760000 fail configuration validation. Gemini retains its 1440000-byte / 512-slab
baseline and rejects the OpenAI capacity profile before opening its provider.
The earlier 30-second examples and memory total describe the baseline profile;
this amendment supersedes only their OpenAI reservoir/slab values.
New OpenAI reservation snapshots freeze `output_backlog_bytes` and
`output_slab_limit`; replay never rewrites them and missing/mismatched profiles
fail admission. Aggregate accounting includes runtime PCM, adapter PCM,
reservations, delivery credit and all unresolved references. Both byte and slab
admission checks run before decoding/extending PCM. Exhaustion remains
`LIVE_BUFFER_OVERFLOW` with `OUTPUT_BACKLOG_CAPACITY` or `OUTPUT_SLAB_CAPACITY`;
a genuine missing-playback deadline remains `PLAYBACK_PROGRESS_STALL`.
Frame size 9600, transport/browser queues 96000, delivery credit 72000, deadlines
and control reception remain unchanged. No provider receive throttling, silent
audio discard, fabricated progress or automatic response chaining is added.
Raw/scratch/copy/metadata payload allowance becomes 6380288 bytes per OpenAI
session under the existing scratch/copy/metadata caps; Python/process overhead
must be measured separately. This finite capacity amendment does not select an
answer token budget or establish real-provider quality/memory acceptance.
### Validated limited-answer behavior
A validated OpenAI response.done with status=incomplete,
status_details.type=incomplete and reason=max_output_tokens, no error, and matching