Schedule consultation bridges on demand and preserve delivery evidence

This commit is contained in:
aiagent
2026-10-20 00:39:12 -07:00
parent 557f1ee03c
commit 2f633869fe
18 changed files with 483 additions and 56 deletions
+28
View File
@@ -123,5 +123,33 @@ class MirrorTests(unittest.TestCase):
client.instance='two'
with self.assertRaisesRegex(RuntimeError,'another control'): sync(Server(),client,cfg)
def test_lost_import_ack_retries_same_external_identity_without_model_execution(self):
class Server:
def history(self,tid):
return {'id':tid},[{'id':'turn','status':'completed','items':[
{'id':'reply','type':'agentMessage','phase':'final_answer','text':'result'}]}]
class Client:
calls=[]
imported={}
lose_ack=True
def call(self,path,data=None):
if path.startswith('/api/messages'):return {'messages':[]}
if path=='/api/state':return {'instance_id':'one'}
self.calls.append(data)
for item in data['items']:self.imported[item['id']]=item
if self.lose_ack:
self.lose_ack=False
raise OSError('server persisted import but response was lost')
return {'deferred':[]}
with tempfile.TemporaryDirectory() as root:
cfg={'thread_id':'thread','session_id':'session','control':{},'state_file':str(Path(root)/'worker.json')}
client=Client()
with self.assertRaises(OSError):sync(Server(),client,cfg)
self.assertFalse((Path(root)/'mirror-state.json').exists())
sync(Server(),client,cfg);sync(Server(),client,cfg)
self.assertEqual(len(client.calls),2)
self.assertEqual(client.calls[0],client.calls[1])
self.assertEqual(list(client.imported),['reply'])
if __name__=='__main__':unittest.main()