fix: relay confirmation interrupts past muted input
This commit is contained in:
@@ -138,7 +138,52 @@ class ClientToolExecutorTests(unittest.IsolatedAsyncioTestCase):
|
||||
|
||||
|
||||
class ClientToolBrokerTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_interrupts_before_resolving_configured_result(self):
|
||||
async def test_uses_configured_downstream_interrupt_handler(self):
|
||||
broker = ClientToolBroker()
|
||||
outbound = []
|
||||
interruptions = []
|
||||
|
||||
async def push_frame(frame, direction=FrameDirection.DOWNSTREAM):
|
||||
outbound.append((frame, direction))
|
||||
|
||||
async def interrupt_after_muted_input():
|
||||
interruptions.append("downstream")
|
||||
|
||||
broker.push_frame = push_frame
|
||||
broker.set_interrupt_handler(interrupt_after_muted_input)
|
||||
call = asyncio.create_task(
|
||||
broker.call(
|
||||
"show_message",
|
||||
{},
|
||||
timeout_seconds=1,
|
||||
response_wait_mode="session",
|
||||
interrupt_on_result=True,
|
||||
)
|
||||
)
|
||||
await asyncio.sleep(0)
|
||||
message = outbound[0][0].message
|
||||
|
||||
await broker.process_frame(
|
||||
InputTransportMessageFrame(
|
||||
message={
|
||||
"type": "client-tool-result",
|
||||
"tool_call_id": message["tool_call_id"],
|
||||
"status": "ok",
|
||||
"data": {"action": "confirmed"},
|
||||
}
|
||||
),
|
||||
FrameDirection.DOWNSTREAM,
|
||||
)
|
||||
|
||||
self.assertEqual(interruptions, ["downstream"])
|
||||
self.assertFalse(call.done())
|
||||
broker.on_interruption_processed()
|
||||
self.assertEqual(
|
||||
await call,
|
||||
{"status": "ok", "data": {"action": "confirmed"}},
|
||||
)
|
||||
|
||||
async def test_resolves_configured_result_after_interruption_processed(self):
|
||||
broker = ClientToolBroker()
|
||||
outbound = []
|
||||
observed_future_states = []
|
||||
@@ -178,6 +223,10 @@ class ClientToolBrokerTests(unittest.IsolatedAsyncioTestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(observed_future_states, [[False]])
|
||||
self.assertFalse(call.done())
|
||||
|
||||
broker.on_interruption_processed()
|
||||
|
||||
self.assertEqual(
|
||||
await call,
|
||||
{"status": "ok", "data": {"action": "confirmed"}},
|
||||
|
||||
Reference in New Issue
Block a user