fix(openai): prompt engineering and transcript model
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
# Persian understanding Phase 3 ? implementation and gated acceptance
|
||||
|
||||
2026-10-11. Scope: Phase 3 only of the [quality plan](../plans/openai-realtime-persian-quality-plan.md).
|
||||
Implementation and empirical acceptance are separate. No provider calls, promotion,
|
||||
new agent, retrieval engine, GPT-Live adapter, migrations or dependencies.
|
||||
|
||||
## Optional reasoning
|
||||
|
||||
`OPENAI_REALTIME_REASONING_EFFORT=null` preserves omission on the provider wire.
|
||||
Only `low` and `medium` are accepted for the exact `gpt-realtime-2.1` and
|
||||
`gpt-realtime-2.1-mini` identifiers. Other explicit combinations fail before
|
||||
provider opening, including settings copies that bypass initial validation.
|
||||
Settings, factory and adapter use the existing paths. OpenAI execution profiles
|
||||
freeze `reasoning` as null or an effort object. Enabled reasoning requires matching
|
||||
provider acknowledgment before readiness; unrequested non-null reasoning fails.
|
||||
Model/effort changes or missing enabled snapshots reject stream admission before
|
||||
opening. Replay preserves identity, request hash and the original snapshot.
|
||||
Use fresh reservations after changes. Gemini profiles and instructions are unchanged.
|
||||
|
||||
The [official Realtime session schema](https://developers.openai.com/api/reference/resources/realtime/client-events)
|
||||
defines session reasoning effort. The [2.1 model](https://developers.openai.com/api/docs/models/gpt-realtime-2.1)
|
||||
and [2.1 mini model](https://developers.openai.com/api/docs/models/gpt-realtime-2.1-mini)
|
||||
are reasoning-capable Realtime candidates. The project restricts effort to its
|
||||
planned low/medium comparison; documentation does not establish account access
|
||||
or empirical cancellation compatibility. No classifier extension is authorized
|
||||
without exact structured candidate evidence; the existing baseline restriction stays.
|
||||
|
||||
## Track A preflight
|
||||
|
||||
[Comparison report](../evaluation/openai-persian-understanding-comparison.json)
|
||||
records exact secret-safe local profiles. Local deployment observation is unverified.
|
||||
Local settings: OpenAI gpt-realtime-mini/shimmer; gpt-transcribe languages fa,en;
|
||||
server VAD threshold 0.5, prefix 300 ms, silence 500 ms, both automatic flags false;
|
||||
noise reduction null; style iranian-persian-professional-v1 and recorded digest.
|
||||
Transport testing is true; no calibration report is configured.
|
||||
All four Phase 4 originals and the Phase 2 calibration original match recorded
|
||||
SHA-256 hashes. Hash identity does not approve originals. The four approvals are
|
||||
pending, document bindings null, factual DOCX inclusion unapproved, four unseen
|
||||
annotations empty. Phase 2 status has cutoff null and a historical configured
|
||||
embedding profile; the report separately records current local embedding identity.
|
||||
No approved actor/binding set exists to verify actual persisted document eligibility,
|
||||
selection, access epoch or embedding compatibility. Those checks remain blocked;
|
||||
no deployment corpus or access is changed. CALIBRATION_REQUIRED remains closed.
|
||||
|
||||
Reuse existing commands only after approvals, identity/bindings and budget exist:
|
||||
|
||||
```powershell
|
||||
.venv/Scripts/python -m app.calibrate_search --user-id <authorized-actor> --bindings <approved-bindings.json> --output <new-measured-report.json> --allow-provider-calls
|
||||
.venv/Scripts/python -m tests.evaluate_search --cases <approved-independent-cases.json> --bindings <approved-bindings.json> --calibration <measured-report.json> --user-id <authorized-actor> --output <new-report.jsonl> --allow-provider-calls --provider-call-budget 26
|
||||
```
|
||||
|
||||
Calibration retains its ten-call cap. Retrieval acceptance retains its 1?26 call
|
||||
budget, original bindings, human review, exact selected corpus, frozen embedding
|
||||
and retrieval policy, final authorization and independent question checks.
|
||||
The CLIs' help was executed without provider calls. Neither calibration nor
|
||||
retrieval evaluation was run. Do not treat draft/status files as measured reports.
|
||||
|
||||
## Track B comparison protocol
|
||||
|
||||
The report contains exact prospective low/medium profiles for both candidates,
|
||||
with all other local settings fixed. These are preparation, not selected ASR/voice
|
||||
or passing profiles. Freeze the human-selected ASR/voice, effective instructions,
|
||||
26 approved dialogue scenarios (20 answerable including every critical case,
|
||||
six unsupported), corpus/bindings, selection and embedding/calibration profile
|
||||
before each comparison. Keep scenarios independent from retrieval labels.
|
||||
No scenarios, labels, speech, listener scores or human approvals were fabricated.
|
||||
|
||||
Each live batch requires explicit authorized models, maximum sessions, audio
|
||||
seconds, tool calls, embedding calls and spend ceiling; credentials are insufficient.
|
||||
Run low first for both models. Only a measured failed understanding gate permits
|
||||
separately identified medium evaluation. Use the same approved recordings and
|
||||
corresponding text inputs diagnostically through existing operator/runtime paths.
|
||||
No automatic evaluation runner or new orchestration was introduced.
|
||||
|
||||
Use the [observation template](../evaluation/openai-persian-understanding-observation.template.json)
|
||||
for each case: independently classify audio interpretation, ASR display, tool query,
|
||||
retrieval and answer failures. Compare human spoken intent, displayed transcript,
|
||||
actual query, returned document/chunk evidence and spoken answer. A transcript
|
||||
error alone is not proof of direct audio misunderstanding. Text success with audio
|
||||
failure supports an audio-stage diagnosis; matching failures require inspecting
|
||||
query/evidence/answer stages. Retain multiple categories when justified.
|
||||
|
||||
Check fresh retrieval before each document follow-up/correction/critical claim,
|
||||
clarification for ambiguous references, exact numbers/dates/conditions/exclusions/
|
||||
negation, all six unsupported responses and technical-error explanations.
|
||||
Exercise selection removal, access revocation, late evidence suppression and fresh
|
||||
sessions. Existing provider-free regressions establish runtime barriers, not model
|
||||
instruction adherence. For each candidate model/voice pair, collect exact structured
|
||||
cancel type/code/param with intent correlation, terminal ordering and matching
|
||||
played-position item/content truncation acknowledgments. Exercise interruption
|
||||
while generating, retrieving and draining completed playback, rapid follow-ups,
|
||||
stop/disconnect and stale-context invalidation. Never widen error matching by text.
|
||||
|
||||
Select only complete passing profiles: independent retrieval gate; >=18/20 answers,
|
||||
all critical, 6/6 unsupported; no invented/stale/unauthorized claims; speech/delivery
|
||||
and lifecycle compatibility gates. Rank understanding, critical speech accuracy,
|
||||
then delivery; latency/cost break equivalent quality. Report p50/p95 on comparable
|
||||
samples; investigate p95 increase >20%. Report observed token/audio usage and
|
||||
known cost or explicit unavailable status. No passing profile exists here; selection
|
||||
is null, live quality/latency/usage/cost unavailable, calls/spend zero.
|
||||
|
||||
## Regression evidence
|
||||
|
||||
Checks and classified failures are recorded in the comparison JSON and appended
|
||||
below after completion. No unrelated evaluation defect is silently repaired.
|
||||
|
||||
- Focused ASR/style/reasoning command: `.venv/Scripts/python -m pytest tests/unit/test_openai_reasoning.py tests/unit/test_openai_speech_configuration.py tests/unit/test_openai_persian_style.py -q -p no:cacheprovider --tb=short`: **51 passed**.
|
||||
- Affected final regression command: `.venv/Scripts/python -m pytest tests/unit/test_openai_reasoning.py tests/unit/test_realtime_phase1.py tests/unit/test_realtime_repairs.py tests/unit/test_realtime_remaining.py tests/unit/test_live_context_sync.py tests/unit/test_search_phase4_gate.py tests/unit/test_search_phase4_repairs.py -q -p no:cacheprovider --tb=short`: **351 passed**, 39.30 s.
|
||||
- Full provider-free command: `.venv/Scripts/python -m pytest -m "not postgres" -q -p no:cacheprovider --tb=short`: **1 failed, 1892 passed, 3 existing Windows symlink skips, 429 deselected**, 326.47 s. Existing `test_real_large_escaped_json_keeps_concurrent_loop_active[4499]` measured 132.03 ms against 100 ms. No related production or test limit was changed.
|
||||
- Focused failure investigation: `.venv/Scripts/python -m pytest tests/unit/test_json_processing.py -q -p no:cacheprovider --tb=short`: **9 passed**, 11.13 s. Full-suite failure remains reported; no definitive cause or all-green regression claim.
|
||||
- Final persisted profile command: `.venv/Scripts/python -m pytest tests/integration/test_openai_speech_profile.py -m postgres --require-postgres -q -p no:cacheprovider --tb=short`: **18 passed**, zero skips, 126.16 s. Includes four acknowledgment cases added after broad suite collection. Fresh task-created loopback database `rag_persian_phase3_test` in container `rag-persian-phase3-20261011-test`, port 55442, PostgreSQL 16.15 / pgvector 0.8.7. Only disposable schemas, no deployment DB writes.
|
||||
- Existing label validators: calibration case structure passed; independent draft retrieval manifest failed closed with `Frozen 20 answerable / 6 unsupported with four unseen cases required` before database/provider setup.
|
||||
- Python AST, report JSON, tracked whitespace, unchanged shared POLICY/Gemini adapter and applied migration byte comparisons passed.
|
||||
|
||||
Phase 3 affected files: configuration.py, voice_provider.py, realtime.py,
|
||||
.env.example, new test_openai_reasoning.py, extended test_openai_speech_profile.py,
|
||||
API catalog, this guide, comparison JSON and observation template, reference map
|
||||
and Phase 3 checkpoint in the plan. Pre-existing speech/style/runtime/transcript
|
||||
and evaluation edits were preserved. No public API/normalized event fields changed.
|
||||
|
||||
- Required broad database command: `.venv/Scripts/python -m pytest -m postgres --require-postgres -q -p no:cacheprovider --tb=short` with process-local isolated TEST_DATABASE_URL: **429 passed, zero skips, 1896 deselected**, 1647.70 s. The final targeted 18-test profile run additionally covered acknowledgment tests added after this collection; counts overlap and must not be summed. No real providers.
|
||||
|
||||
Implementation status: implemented. Acceptance status: blocked. The unrelated
|
||||
provider-free full-suite failure remains unresolved; real calibrated retrieval,
|
||||
26-case dialogue quality, native speech scores and exact candidate interruption
|
||||
compatibility remain not_run. Quality/latency/usage/cost cannot be inferred from
|
||||
these regressions. Phase 3 is not closed and no complete profile is promoted.
|
||||
|
||||
Cleanup confirmed zero disposable test schemas and zero public tables. The task-created container and its anonymous volume were removed; pre-existing containers were preserved.
|
||||
|
||||
|
||||
## Operational calibration checkpoint — 2026-10-11
|
||||
|
||||
After the implementation checkpoint above, the user approved the ten-case sample
|
||||
and authorized execution. [The activation handoff](search-calibration-activation-2026-10-11.md)
|
||||
records actual intake, selection, measured 6/6 complete support and zero unsupported
|
||||
false positives across four cases, ten local embedding queries, and activation of
|
||||
the measured report in the main API with transport-testing bypass disabled.
|
||||
The calibration prerequisite is now satisfied in this environment. Independent
|
||||
26-case acceptance, real OpenAI voice quality and candidate interruption evidence
|
||||
remain pending; this operational result does not close Phase 3 or promote a fully
|
||||
validated speech profile. Earlier zero-provider-call statements describe the
|
||||
implementation checkpoint, not this subsequent calibration workflow.
|
||||
Reference in New Issue
Block a user