fix: reconcile uncertain voice admission with bounded cancellation
This commit is contained in:
1 parent
0cb00e6095
commit
0c57217ad9
3 files changed
+40
-4
No files matched your search
@@ -174,6 +174,31 @@ class ConversationLLMTests(unittest.IsolatedAsyncioTestCase):
|
||||
await asyncio.gather(consumer, return_exceptions=True)
|
||||
await bridge.aclose()
|
||||
|
||||
async def test_normal_lost_admission_receipt_persists_key_cancellation(self):
|
||||
requests, progress_events = [], []
|
||||
async def handler(request):
|
||||
requests.append(request.url.path)
|
||||
if request.url.path.endswith('/messages'):
|
||||
raise httpx.ReadError('Offline accepted admission receipt lost', request=request)
|
||||
if '/operations/' in request.url.path and request.url.path.endswith('/cancel'):
|
||||
return httpx.Response(200, json={'ok': True})
|
||||
self.fail('Unknown admission identity must not stream or invent a run stop')
|
||||
async def progress(value): progress_events.append(value)
|
||||
bridge = ConversationLLM(control_url='https://offline.test', secret='offline', room_id='bound-room', on_progress=progress)
|
||||
await bridge.client.aclose()
|
||||
bridge.client = httpx.AsyncClient(transport=httpx.MockTransport(handler))
|
||||
context = llm.ChatContext([llm.ChatMessage(role='user', content=['Lost receipt without barge-in'])])
|
||||
try:
|
||||
with self.assertRaises(Exception):
|
||||
async with bridge.chat(chat_ctx=context) as stream:
|
||||
async for _ in stream:
|
||||
self.fail('No answer is safe after uncertain admission failure')
|
||||
self.assertEqual(requests, ['/internal/chat/rooms/bound-room/messages',
|
||||
'/internal/chat/rooms/bound-room/operations/' + context.items[-1].id + '/cancel'])
|
||||
self.assertEqual(progress_events[-1]['status'], 'failed')
|
||||
finally:
|
||||
await bridge.aclose()
|
||||
|
||||
async def test_key_cancel_receipt_prevents_late_rejected_admission_action(self):
|
||||
entered, release, tombstoned = asyncio.Event(), asyncio.Event(), asyncio.Event()
|
||||
requests, progress_events = [], []
|
||||
|
||||
Reference in new issue
Block a user