@@ -59,11 +59,13 @@ def url(self) -> str:
5959 def evaluate (self , script : str , * args : Any , ** kwargs : Any ) -> Any :
6060 # Return proper snapshot structure when snapshot is called
6161 # The script is a function that calls window.sentience.snapshot(options)
62- if "window.sentience.snapshot" in script or ("snapshot" in script .lower () and "options" in script ):
62+ if "window.sentience.snapshot" in script or (
63+ "snapshot" in script .lower () and "options" in script
64+ ):
6365 # Check if args contain options (for empty snapshot tests)
6466 options = kwargs .get ("options" ) or (args [0 ] if args else {})
6567 limit = options .get ("limit" , 50 ) if isinstance (options , dict ) else 50
66-
68+
6769 # Return elements based on limit (0 for empty snapshot tests)
6870 elements = []
6971 if limit > 0 :
@@ -84,7 +86,7 @@ def evaluate(self, script: str, *args: Any, **kwargs: Any) -> Any:
8486 "z_index" : 10 ,
8587 }
8688 ]
87-
89+
8890 # Snapshot model expects 'elements' not 'raw_elements'
8991 return {
9092 "status" : "success" ,
@@ -236,9 +238,7 @@ def test_agent_handles_malformed_llm_response(self):
236238 llm = MockLLMProvider (responses = ["INVALID_RESPONSE_FORMAT" ])
237239 agent = SentienceAgent (browser , llm , verbose = False )
238240
239- with (
240- patch ("sentience.snapshot.snapshot" ) as mock_snapshot ,
241- ):
241+ with (patch ("sentience.snapshot.snapshot" ) as mock_snapshot ,):
242242 mock_snapshot .return_value = create_mock_snapshot ()
243243
244244 # Action executor should raise ValueError for invalid format
@@ -365,7 +365,9 @@ def test_agent_handles_unicode_in_actions(self):
365365 from sentience .models import ActionResult
366366
367367 mock_snapshot .return_value = create_mock_snapshot ()
368- mock_type .return_value = ActionResult (success = True , duration_ms = 200 , outcome = "dom_updated" )
368+ mock_type .return_value = ActionResult (
369+ success = True , duration_ms = 200 , outcome = "dom_updated"
370+ )
369371
370372 result = agent .act ("Type 你好世界" , max_retries = 0 )
371373 assert result .success is True
@@ -385,7 +387,9 @@ def test_agent_handles_special_characters_in_goal(self):
385387 from sentience .models import ActionResult
386388
387389 mock_snapshot .return_value = create_mock_snapshot ()
388- mock_click .return_value = ActionResult (success = True , duration_ms = 150 , outcome = "dom_updated" )
390+ mock_click .return_value = ActionResult (
391+ success = True , duration_ms = 150 , outcome = "dom_updated"
392+ )
389393
390394 # Test with special characters
391395 result = agent .act ('Click the "Submit" button (with quotes)' , max_retries = 0 )
@@ -435,9 +439,10 @@ def test_agent_handles_tracer_errors_gracefully(self):
435439 from sentience .models import ActionResult
436440
437441 mock_snapshot .return_value = create_mock_snapshot ()
438- mock_click .return_value = ActionResult (success = True , duration_ms = 150 , outcome = "dom_updated" )
442+ mock_click .return_value = ActionResult (
443+ success = True , duration_ms = 150 , outcome = "dom_updated"
444+ )
439445
440446 # Agent should still complete action despite tracer error
441447 result = agent .act ("Click the button" , max_retries = 0 )
442448 assert result .success is True
443-
0 commit comments