fix(voice): preserve interrupted searches and report used sources
Retain and revalidate interrupted searches, resolve abandoned provider calls, recover invalid source reports privately, and expose only declared sources. Improve Persian delivery and provider event replay capacity. Include regression coverage and contract updates.
This commit is contained in:
@@ -54,11 +54,16 @@ def test_same_topic_reuses_original_retrieval_and_new_topic_searches(runner, per
|
||||
assert reused['ref'] == original['ref'] and reused['durable_id'] == original['durable_id']
|
||||
expected = dict(original['result']['sources'][0], source_ref='S2' if existing_source else 'S1')
|
||||
assert reused['result']['sources'] == [expected]
|
||||
await until(lambda: any(isinstance(e, dict) and e.get('type') == 'sources' and e.get('turn_ref') == 'live-turn-2' for e in out))
|
||||
event = next(e for e in out if isinstance(e, dict) and e.get('type') == 'sources' and e.get('turn_ref') == 'live-turn-2')
|
||||
assert event['tool_call_id'] == original['ref']
|
||||
assert not any(isinstance(e, dict) and e.get('type') == 'sources' for e in out)
|
||||
await response(runtime, wire, 'r4')
|
||||
await runtime.handle(call('r4', 'reported', name='report_used_sources',
|
||||
raw='{"source_refs":["' + expected['source_ref'] + '"]}'))
|
||||
await done(runtime, 'r4')
|
||||
await until(lambda: any(isinstance(e, dict) and e.get('type') == 'sources' for e in out))
|
||||
event = next(e for e in out if isinstance(e, dict) and e.get('type') == 'sources')
|
||||
assert event['turn_ref'] == 'live-turn-2' and event['tool_call_id'] == original['ref']
|
||||
await response(runtime, wire, 'reported-answer')
|
||||
await done(runtime, 'reported-answer')
|
||||
await input_turn(runtime, 'u3', 420)
|
||||
await response(runtime, wire, 'r5')
|
||||
await runtime.handle(call('r5', 'c3', query='new topic'))
|
||||
@@ -91,7 +96,7 @@ def test_reuse_without_valid_bundle_never_searches_or_accepts_scope(runner, pers
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_interrupted_turn_clears_evidence_before_continuation(runner, persisted):
|
||||
def test_interrupted_turn_retains_evidence_without_releasing_old_response(runner, persisted):
|
||||
async def scenario():
|
||||
runtime, wire, _ = await make(SimpleNamespace(engine=None), runner, persisted)
|
||||
try:
|
||||
@@ -99,7 +104,7 @@ def test_interrupted_turn_clears_evidence_before_continuation(runner, persisted)
|
||||
origin = await response(runtime, wire)
|
||||
runtime.last_evidence = (origin, dict(durable_id=uuid4(), result=dict(status='ok', sources=[])))
|
||||
await input_turn(runtime, 'u2', 210)
|
||||
assert runtime.last_evidence is None and origin.interrupted and origin.turn.cancelled.is_set()
|
||||
assert runtime.last_evidence[0] is origin and origin.interrupted and origin.turn.cancelled.is_set()
|
||||
finally:
|
||||
await runtime.close()
|
||||
asyncio.run(scenario())
|
||||
|
||||
Reference in New Issue
Block a user