217 lines
14 KiB
Markdown
217 lines
14 KiB
Markdown
# OpenAI Live context synchronization repair - 2026-10-10
|
|
|
|
The local OpenAI cancellation-race defect is reproduced and corrected. This is
|
|
not proof that the historical browser incident had this branch or that the
|
|
deployed browser/API is repaired. No operational rebuild or restart was performed.
|
|
|
|
## Confirmed cause and evidence
|
|
|
|
[RealtimeAdapter.is_no_active](../../app/infrastructure/realtime.py) previously
|
|
returned false unless a separately injected classifier was supplied.
|
|
[create_adapter](../../app/infrastructure/voice_provider.py) supplies no classifier.
|
|
A response can finish between the runtime's active-state check and provider
|
|
processing of its response-specific cancellation. The correlated no-active error
|
|
therefore reached the cancellation-provider-error branch in
|
|
[VoiceRuntime.handle](../../app/modules/voice/runtime.py), which called
|
|
LIVE_CONTEXT_SYNC_FAILED even when response.done had already confirmed completion.
|
|
|
|
Current [official client-event documentation](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
|
says cancelling without an active response returns an error and leaves the
|
|
provider session unaffected. That establishes the semantics, not a stable
|
|
structured error-code spelling. The governing API catalog Section 7.1.6 requires
|
|
selected-profile verification before accepting a structured cancellation race.
|
|
|
|
After explicit user authorization, one isolated OpenAI connection produced
|
|
two short responses using the existing gpt-realtime-mini/shimmer configuration.
|
|
The first completed; its response-specific cancellation returned the exact
|
|
structured fields type=invalid_request_error, code=response_cancel_not_active,
|
|
param=null, correlated to that cancellation event_id. Truncation of that
|
|
completed audio at zero milliseconds was then confirmed by matching item,
|
|
content_index=0 and audio_end_ms=0. During the second response cancellation was
|
|
dispatched after an audio delta; response.done reported completed, so this does
|
|
not prove provider status=cancelled or all active-generation interruption behavior.
|
|
The [sanitized probe evidence](../calibration/live-context-sync-probe.json)
|
|
contains no raw audio, transcripts, full provider events, messages, identities,
|
|
credentials or tool data. The probe's bounded three-second transport-close
|
|
operation timed out and the isolated process exited; cleanup timeout remains an
|
|
observed limitation, not a successful close-handshake claim.
|
|
|
|
The three captured-provider synthetic regressions failed before the classifier
|
|
fix with CANCELLATION_PROVIDER_ERROR and LIVE_CONTEXT_SYNC_FAILED. Their controlled
|
|
sequences covered terminal-before-error, terminal-after-error, and absent terminal
|
|
confirmation. After correction, both confirmed-terminal orderings safely complete
|
|
truncation and release the next response; the absent-terminal case still times out.
|
|
|
|
The available tail of operational diagnostics did not contain application session
|
|
ce371f61-6bed-4863-a091-61fe116f1be1 or identify its branch. Historical browser
|
|
events and the public error code cannot establish that this defect caused that
|
|
specific incident. During inspection the running API selected Gemini; its
|
|
dedicated OpenAI settings remained gpt-realtime-mini/shimmer with a configured
|
|
key. An initial probe guard exited before any connection because the selected
|
|
provider was Gemini. The authorized probe then used the dedicated OpenAI settings
|
|
directly without changing the API's selected provider or model configuration.
|
|
|
|
## Correction and safety
|
|
|
|
The adapter now recognizes only the verified gpt-realtime-mini/shimmer profile
|
|
and exact structured type/code with a null or absent param. No provider message
|
|
substring is inspected. Other profiles and error types/codes/parameters remain
|
|
unaccepted. Existing trusted classifier injection remains available for separately
|
|
verified profiles and deterministic fixtures.
|
|
|
|
The runtime independently requires error.event_id to match one dispatched
|
|
response-specific cancellation intent. This error neither retries cancellation
|
|
nor substitutes for terminal confirmation, final playback position, or truncation
|
|
acknowledgment. Generic/unrelated errors, truncation errors, missing terminal events,
|
|
mismatched cleanup, changed late progress and transport uncertainty remain fatal.
|
|
Failed/incomplete terminal responses retain LIVE_PROVIDER_UNAVAILABLE; protocol
|
|
and send failures retain their existing technical categories. Public errors,
|
|
PCM layout, authorization/epochs, retrieval, replay fencing, buffer bounds and
|
|
production deadlines are unchanged. Applied migrations and unrelated working-tree
|
|
edits were preserved.
|
|
|
|
Causal synthetic sequence:
|
|
|
|
1. Trusted speech starts; unfinished old output is superseded, delivery stops,
|
|
refs enter finalizing and cancellation is queued once. turn_interrupted precedes
|
|
user_speech_started for the next turn.
|
|
2. Final browser progress is accepted while the original reporting window is open.
|
|
Tests advance heard position from 100 to 420 ms without restarting the window.
|
|
3. The old response's response.done and no-active cancellation error can arrive in
|
|
either order. A verified error is benign only under its mapped cancellation;
|
|
independent terminal confirmation remains required.
|
|
4. At window expiry progress freezes. All generated but unconfirmed audio still
|
|
requires conversation.item.truncate at the frozen position.
|
|
5. Only a matching item/content/position acknowledgment retires the ref. Input
|
|
stop/commit plus completed old work then permit the next response.
|
|
6. Duplicate acknowledgments and late old cancellation errors do not alter the new
|
|
response. Missing terminal confirmation and unsafe cleanup fail closed.
|
|
|
|
## Private diagnostic coverage
|
|
|
|
[Runtime.sync_failed](../../app/modules/voice/runtime.py) records the first
|
|
accepted synchronization failure before retiring state.
|
|
[Diagnostics](../../app/modules/voice/diagnostics.py) allowlist numeric fields and
|
|
clamp each to a signed 32-bit range. Records contain application session ID,
|
|
runtime phase, stable reason, allowlisted provider event type, exception class,
|
|
public failure category, deadline remaining milliseconds where applicable,
|
|
pending command/response/audio counts and outstanding input bytes; audio-related
|
|
branches also record sent_bytes and accepted played_ms where a part is known.
|
|
Unknown event types, arbitrary exception text, provider messages and payloads are
|
|
never logged.
|
|
|
|
| Failure branch | Internal reason |
|
|
| --- | --- |
|
|
| Response creation acknowledgment deadline | RESPONSE_ACK_DEADLINE |
|
|
| Input commit/consumption deadline | INPUT_COMMIT_DEADLINE |
|
|
| Cancellation terminal acknowledgment deadline | CANCELLATION_ACK_DEADLINE |
|
|
| Truncation acknowledgment deadline | TRUNCATION_ACK_DEADLINE |
|
|
| Truncation item/content mismatch | TRUNCATION_ACK_IDENTITY_MISMATCH |
|
|
| Truncation heard-position mismatch | TRUNCATION_ACK_POSITION_MISMATCH |
|
|
| Unaccepted correlated cancellation error | CANCELLATION_PROVIDER_ERROR |
|
|
| Correlated truncation error | TRUNCATION_PROVIDER_ERROR |
|
|
| Unrelated provider error during cleanup | UNRELATED_PROVIDER_ERROR_DURING_SYNC |
|
|
| Receive transport loss during cleanup | PROVIDER_TRANSPORT_LOST_DURING_SYNC |
|
|
| Adapter receive/send context capability failure | ADAPTER_CONTEXT_UNSUPPORTED / ADAPTER_CONTEXT_COMMAND_UNSUPPORTED |
|
|
| Tool continuation before its outputs are sent | TOOL_CONTINUATION_OUTPUT_UNSENT |
|
|
| Provider queue/send deadline | PROVIDER_COMMAND_QUEUE_DEADLINE / PROVIDER_COMMAND_SEND_DEADLINE |
|
|
| Client audio/control send deadline | CLIENT_AUDIO_SEND_DEADLINE / CLIENT_CONTROL_SEND_DEADLINE |
|
|
| Provider send exception | PROVIDER_SEND_FAILED |
|
|
|
|
Transport deadlines retain LIVE_TRANSPORT_FAILED; detailed reasons do not change
|
|
the public error envelope or overwrite the immutable first failure.
|
|
|
|
## Executed validation
|
|
|
|
New [controlled-clock regressions](../../tests/unit/test_live_context_sync.py)
|
|
cover captured cancellation errors before/after terminal completion, missing
|
|
terminal confirmation, exact classifier negatives/profile restrictions, active
|
|
audio interruption, completed generation with undrained playback, final progress,
|
|
truncation position, duplicate acknowledgments, late errors after a new response,
|
|
all four synchronization deadlines, privacy/bounds, transport/protocol categories,
|
|
failed/incomplete response classification and concurrent runtime close.
|
|
|
|
The existing focused suite additionally covers rapid/repeated speech starts,
|
|
normal/late progress, identity/replay fencing, cancellation send races, unsafe
|
|
synchronization, authority and bounded resource ownership.
|
|
[Database incident tests](../../tests/integration/test_voice_session_incident.py)
|
|
now include LIVE_CONTEXT_SYNC_FAILED in the concurrent-close persistence cases.
|
|
|
|
| Command | Actual outcome |
|
|
| --- | --- |
|
|
| git diff --check | Passed, including final report changes. Existing Git CRLF conversion warnings remain. |
|
|
| .venv/Scripts/python -m pytest tests/unit/test_live_context_sync.py -q -p no:cacheprovider --tb=short | Final 25 passed in 3.57 s. |
|
|
| .venv/Scripts/python -m pytest tests/unit/test_live_context_sync.py tests/unit/test_voice_session_incident.py tests/unit/test_realtime_phase1.py tests/unit/test_realtime_repairs.py tests/unit/test_realtime_remaining.py -q -p no:cacheprovider --tb=short | 313 passed in 31.23 s before four final category regressions were added; final full run below includes them. |
|
|
| .venv/Scripts/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short | Final 1827 passed, 3 Windows symlink skips, 415 PostgreSQL cases deselected, 25 existing deprecation warnings, 253.84 s. |
|
|
| .venv/Scripts/python -m pytest tests/integration/test_voice_session_incident.py -m postgres --require-postgres -q -p no:cacheprovider --tb=short | 11 passed in 33.67 s, zero skips. |
|
|
|
|
Database acceptance used only task-created container
|
|
rag-context-sync-20261010-test, loopback port 55439 and dedicated database
|
|
rag_context_sync_test with Psycopg. TEST_DATABASE_URL was set only in that
|
|
PowerShell process. Fixtures apply existing immutable migrations to disposable
|
|
schemas; they do not use operational/public application tables. The verified
|
|
task-owned container and anonymous test storage were removed after acceptance.
|
|
No full 415-case PostgreSQL acceptance run was executed for this adapter/runtime
|
|
change; durable implementation and migrations were not changed.
|
|
|
|
Intermediate evidence: captured-provider regressions failed 3/3 before correction.
|
|
Initial diagnostic tests passed 11/11. An earlier full ordinary run had
|
|
1812 passed, 3 skips and one unrelated
|
|
test_real_large_escaped_json_keeps_concurrent_loop_active[10000] failure
|
|
(max heartbeat gap 144.03 ms against 100 ms). A focused suite ran concurrently
|
|
during that earlier run. The final full run was not paired with another test suite
|
|
and passed this unchanged test. The timing failure is recorded, not removed,
|
|
weakened, or asserted to have a definitively established cause.
|
|
|
|
## Frontend and deployment handoff
|
|
|
|
Only data/temp frontend copies were found; no accessible authoritative Angular
|
|
workspace was found. Inspection confirms clearPlayback discards queued/deferred
|
|
audio, and audio_ended requests a drain. The prior whole-second synthetic test
|
|
does not establish browser interruption/progress ordering or audio_ref ownership.
|
|
No frontend file was edited and no deployed frontend repair is claimed. Missing
|
|
zero progress remains conservatively zero in the backend; real per-reference
|
|
final reports and timing still need browser acceptance.
|
|
|
|
No frontend patch is required by the reproduced backend classifier defect.
|
|
Browser acceptance must still verify normal turns, interruption during generation,
|
|
interruption after generation before playback drains, two rapid utterances,
|
|
manual stop, accurate truncation, stable terminal state and one cleanup request.
|
|
The authorized provider probe is not microphone/Persian/browser acceptance and
|
|
did not exercise the corrected application stream against OpenAI.
|
|
|
|
Changes are prepared locally. No docker compose build api or docker compose up
|
|
was executed, no deployed source-match/readiness claim is made, and provider
|
|
selection was not changed. Deploy only when separately authorized, then verify
|
|
corrected adapter/runtime files and readiness inside the running API and use a
|
|
fresh voice session. This incident is not claimed fully resolved without historical
|
|
attribution or the remaining deployed browser validation.
|
|
|
|
## Additional observed profile (2026-10-12)
|
|
|
|
The live-conversation incident plan records the same structured
|
|
`invalid_request_error` / `response_cancel_not_active` / null-param signature
|
|
for `gpt-realtime-2.1/shimmer`. The adapter accepts this exact profile and
|
|
signature alongside the previously probed `gpt-realtime-mini/shimmer`.
|
|
Runtime event-ID, terminal response, and unheard-audio truncation gates remain
|
|
mandatory. The incident observation is profile-specific evidence; this change
|
|
does not establish that cancellation acknowledgement deadlines are resolved.
|
|
|
|
### Verified Marin cancellation race (2026-10-13)
|
|
|
|
Operational session 79421770-4615-4140-ae2f-fc590510787d pinned
|
|
`gpt-realtime-2.1/marin`. Turn 7 cancellation was dispatched at elapsed 44499 ms;
|
|
completed terminal confirmation arrived at 44677 ms. The correlated error then
|
|
matched all three exact structured type/code/null-param guards but failed the
|
|
Shimmer-only profile guard, closing with CANCELLATION_PROVIDER_ERROR.
|
|
The verified profile set now additionally includes gpt-realtime-2.1/marin.
|
|
It does not admit other model/voice pairs or relax event-ID correlation,
|
|
terminal confirmation, final playback positions or truncation acknowledgement.
|
|
Synthetic regressions reproduce the original rejection, cover both terminal
|
|
orderings, and retain failure when terminal confirmation is absent.
|
|
|
|
Verification: four new regression assertions failed before the fix;
|
|
114 focused synchronization, interruption and retained-search tests passed
|
|
afterward. A default-disabled trace test now isolates the operator .env.
|
|
Post-fix real microphone acceptance remains pending a fresh Marin session.
|