|
1 | | -import asyncio |
2 | 1 | import traceback |
3 | 2 | from typing import Any, Optional, Union |
4 | 3 |
|
@@ -47,31 +46,6 @@ async def act(self, options: Union[ActOptions, ObserveResult]) -> ActResult: |
47 | 46 | options, self.stagehand.dom_settle_timeout_ms |
48 | 47 | ) |
49 | 48 |
|
50 | | - # Extract timeout_ms from options (check both snake_case and camelCase) |
51 | | - ## TODO - this is a temporary fix to support the timeout_ms field in the options. |
52 | | - ## We should update the options to use the timeout_ms field instead of timeoutMs. |
53 | | - timeout_ms = options.get("timeout_ms") or options.get("timeoutMs") |
54 | | - |
55 | | - # If timeout is specified, wrap the entire act operation with asyncio.wait_for |
56 | | - if timeout_ms: |
57 | | - try: |
58 | | - return await asyncio.wait_for( |
59 | | - self._perform_act_with_timeout(options), |
60 | | - timeout=timeout_ms / 1000.0, # Convert ms to seconds |
61 | | - ) |
62 | | - except asyncio.TimeoutError: |
63 | | - action_task = options.get("action") |
64 | | - return ActResult( |
65 | | - success=False, |
66 | | - message=f"Action timed out after {timeout_ms}ms", |
67 | | - action=action_task, |
68 | | - ) |
69 | | - else: |
70 | | - # No timeout specified, use existing behavior |
71 | | - return await self._perform_act_with_timeout(options) |
72 | | - |
73 | | - async def _perform_act_with_timeout(self, options) -> ActResult: |
74 | | - """Extract the main act logic into a separate method for timeout handling""" |
75 | 49 | # Start inference timer if available |
76 | 50 | if hasattr(self.stagehand, "start_inference_timer"): |
77 | 51 | self.stagehand.start_inference_timer() |
|
0 commit comments