feat(voice): specialize prompt for Isfahan Industrial Parks, emit source excerpts, and bound generation

- Specialize voice assistant identity and agent system prompt for «شرکت شهرک‌های صنعتی اصفهان» (English instructions with Persian proper names)
- Emit bounded chunk text excerpts (up to 2000 chars) and identify primary_source in realtime sources events
- Bound OpenAI output generation via OPENAI_REALTIME_MAX_OUTPUT_TOKENS and add answer_limited event
- Handle old-turn search cancellation safely on turn supersession
- Add end-to-end search tracing pipeline and diagnostic CLI
- Add database organization title and settings update script
This commit is contained in:
amirhosein mazaheri
2026-10-12 17:35:28 +03:30
parent f14166a89f
commit 117fda7cc9
29 changed files with 1476 additions and 67 deletions
+19 -5
View File
@@ -142,9 +142,10 @@ def test_actual_canonical_tool_and_duplicate_continuation(settings, monkeypatch,
await runtime.handle(event)
await runtime.handle(event)
await runtime.handle(dict(event, event_id="semantic-duplicate"))
await until(lambda: runtime.calls["c1"][1]["result"] is not None)
assert runtime.calls["c1"][1]["result"] is None
assert not commands(transport, "conversation.item.create")
await done(runtime)
await until(lambda: runtime.calls["c1"][1]["result"] is not None)
await until(lambda: commands(transport, "conversation.item.create"))
await done(runtime)
await until(lambda: len(commands(transport, "response.create")) == 2)
@@ -236,11 +237,13 @@ def test_retrieval_does_not_block_receive_and_interruption_cancels(runner, persi
await input_turn(runtime)
await response(runtime, transport)
await runtime.handle(call())
assert not entered.is_set()
await done(runtime)
await until(entered.is_set)
await runtime.handle(dict(type="input_audio_buffer.speech_started", item_id="u2", audio_start_ms=10))
assert runtime.inputs["u1"].cancelled.is_set()
await until(lambda: commands(transport, "response.cancel"))
assert commands(transport, "response.cancel")[0]["response_id"] == "r1"
assert runtime.responses["r1"].terminal
assert not commands(transport, "response.cancel")
finish.set()
await until(lambda: not runtime.tasks)
assert not commands(transport, "conversation.item.create")
@@ -485,17 +488,28 @@ def test_authority_revocation_gates_continuation(runner, persisted):
async def scenario():
runtime, transport, out = await make(SimpleNamespace(engine=None,
search=lambda *_: dict(status="no_evidence", sources=[])), runner, persisted)
entered, resume = asyncio.Event(), asyncio.Event()
trusted = runtime.authority_check
async def continuation_authority(execution):
entered.set()
await resume.wait()
return await trusted(execution)
try:
await input_turn(runtime)
await response(runtime, transport)
await runtime.handle(call())
await until(lambda: runtime.calls["c1"][1]["result"] is not None)
persisted["epoch"] += 1
assert runtime.calls["c1"][1]["result"] is None
runtime.authority_check = continuation_authority
await done(runtime)
await until(lambda: runtime.calls["c1"][1]["result"] is not None)
await until(entered.is_set)
persisted["epoch"] += 1
resume.set()
await until(lambda: runtime.failure is not None)
assert runtime.failure == "CONTEXT_REVOKED"
assert not commands(transport, "conversation.item.create")
finally:
resume.set()
await runtime.close()
asyncio.run(scenario())