From 123f95ae255de19807b16c5fc0a0f62fdb2cf719 Mon Sep 17 00:00:00 2001 From: Jagjeevan Kashid Date: Mon, 22 Sep 2025 15:25:25 +0530 Subject: [PATCH] fixed issue 344 Signed-off-by: Jagjeevan Kashid --- libs/python/agent/agent/computers/base.py | 8 ++++++-- libs/python/agent/agent/computers/cua.py | 8 ++++++-- libs/python/agent/agent/computers/custom.py | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libs/python/agent/agent/computers/base.py b/libs/python/agent/agent/computers/base.py index 7fbcb0f7..358fbbf4 100644 --- a/libs/python/agent/agent/computers/base.py +++ b/libs/python/agent/agent/computers/base.py @@ -19,8 +19,12 @@ class AsyncComputerHandler(Protocol): """Get screen dimensions as (width, height).""" ... - async def screenshot(self) -> str: - """Take a screenshot and return as base64 string.""" + async def screenshot(self, text: Optional[str] = None) -> str: + """Take a screenshot and return as base64 string. + + Args: + text: Optional descriptive text (for compatibility with GPT-4o models, ignored) + """ ... async def click(self, x: int, y: int, button: str = "left") -> None: diff --git a/libs/python/agent/agent/computers/cua.py b/libs/python/agent/agent/computers/cua.py index f935be5b..40337950 100644 --- a/libs/python/agent/agent/computers/cua.py +++ b/libs/python/agent/agent/computers/cua.py @@ -33,8 +33,12 @@ class cuaComputerHandler(AsyncComputerHandler): screen_size = await self.interface.get_screen_size() return screen_size["width"], screen_size["height"] - async def screenshot(self) -> str: - """Take a screenshot and return as base64 string.""" + async def screenshot(self, text: Optional[str] = None) -> str: + """Take a screenshot and return as base64 string. + + Args: + text: Optional descriptive text (for compatibility with GPT-4o models, ignored) + """ assert self.interface is not None screenshot_bytes = await self.interface.screenshot() return base64.b64encode(screenshot_bytes).decode('utf-8') diff --git a/libs/python/agent/agent/computers/custom.py b/libs/python/agent/agent/computers/custom.py index b5f801b6..5ab7d535 100644 --- a/libs/python/agent/agent/computers/custom.py +++ b/libs/python/agent/agent/computers/custom.py @@ -120,8 +120,12 @@ class CustomComputerHandler(AsyncComputerHandler): return self._last_screenshot_size - async def screenshot(self) -> str: - """Take a screenshot and return as base64 string.""" + async def screenshot(self, text: Optional[str] = None) -> str: + """Take a screenshot and return as base64 string. + + Args: + text: Optional descriptive text (for compatibility with GPT-4o models, ignored) + """ result = await self._call_function(self.functions['screenshot']) b64_str = self._to_b64_str(result) # type: ignore