@@ -397,6 +397,50 @@ def click(self, x: int, y: int, button: str) -> None:
397397 assert "does not accept keyword argument(s) keys" in caplog .text
398398
399399
400+ @pytest .mark .asyncio
401+ async def test_get_screenshot_drops_modifier_keys_for_non_introspectable_driver_with_warning (
402+ caplog : pytest .LogCaptureFixture ,
403+ ) -> None :
404+ class NonIntrospectableClick :
405+ def __init__ (self , calls : list [tuple [str , tuple [Any , ...]]]) -> None :
406+ self ._calls = calls
407+
408+ @property
409+ def __signature__ (self ) -> Any :
410+ raise ValueError ("signature unavailable" )
411+
412+ def __call__ (self , x : int , y : int , button : str ) -> None :
413+ self ._calls .append (("click" , (x , y , button )))
414+
415+ class NonIntrospectableDriver :
416+ def __init__ (self ) -> None :
417+ self .calls : list [tuple [str , tuple [Any , ...]]] = []
418+ self .click = NonIntrospectableClick (self .calls )
419+
420+ def screenshot (self ) -> str :
421+ self .calls .append (("screenshot" , ()))
422+ return "non_introspectable"
423+
424+ tool_call = ResponseComputerToolCall (
425+ id = "c8" ,
426+ type = "computer_call" ,
427+ action = _action_with_keys (
428+ ActionClick , type = "click" , x = 2 , y = 5 , button = "left" , keys = ["shift" ]
429+ ),
430+ call_id = "c8" ,
431+ pending_safety_checks = [],
432+ status = "completed" ,
433+ )
434+
435+ driver = NonIntrospectableDriver ()
436+ with caplog .at_level (logging .WARNING , logger = "openai.agents" ):
437+ screenshot_output = await ComputerAction ._execute_action_and_capture (driver , tool_call )
438+
439+ assert driver .calls == [("click" , (2 , 5 , "left" )), ("screenshot" , ())]
440+ assert screenshot_output == "non_introspectable"
441+ assert "does not accept keyword argument(s) keys" in caplog .text
442+
443+
400444@pytest .mark .asyncio
401445async def test_get_screenshot_preserves_modifier_keys_for_kwargs_driver () -> None :
402446 class KwargsDriver :
@@ -411,10 +455,10 @@ def move(self, x: int, y: int, **kwargs: Any) -> None:
411455 self .calls .append (("move" , (x , y ), kwargs ))
412456
413457 tool_call = ResponseComputerToolCall (
414- id = "c8 " ,
458+ id = "c9 " ,
415459 type = "computer_call" ,
416460 action = _action_with_keys (ActionMove , type = "move" , x = 10 , y = 12 , keys = ["meta" ]),
417- call_id = "c8 " ,
461+ call_id = "c9 " ,
418462 pending_safety_checks = [],
419463 status = "completed" ,
420464 )
@@ -433,12 +477,12 @@ def move(self, x: int, y: int, **kwargs: Any) -> None:
433477async def test_get_screenshot_preserves_modifier_keys_for_batched_actions () -> None :
434478 computer = LoggingComputer (screenshot_return = "batched_keys" )
435479 tool_call = ResponseComputerToolCall (
436- id = "c9 " ,
480+ id = "c10 " ,
437481 type = "computer_call" ,
438482 actions = [
439483 _action_with_keys (BatchedClick , type = "click" , x = 11 , y = 12 , button = "left" , keys = ["ctrl" ])
440484 ],
441- call_id = "c9 " ,
485+ call_id = "c10 " ,
442486 pending_safety_checks = [],
443487 status = "completed" ,
444488 )
0 commit comments