diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.py index 536fb341..e4746878 100644 --- a/libs/python/agent/agent/agent.py +++ b/libs/python/agent/agent/agent.py @@ -22,7 +22,7 @@ from .callbacks import ( TelemetryCallback, ) from .computers import ( - ComputerHandler, + AsyncComputerHandler, is_agent_computer, make_computer_handler ) @@ -398,7 +398,7 @@ class ComputerAgent: # AGENT OUTPUT PROCESSING # ============================================================================ - async def _handle_item(self, item: Any, computer: Optional[ComputerHandler] = None, ignore_call_ids: Optional[List[str]] = None) -> List[Dict[str, Any]]: + async def _handle_item(self, item: Any, computer: Optional[AsyncComputerHandler] = None, ignore_call_ids: Optional[List[str]] = None) -> List[Dict[str, Any]]: """Handle each item; may cause a computer action + screenshot.""" if ignore_call_ids and item.get("call_id") and item.get("call_id") in ignore_call_ids: return [] diff --git a/libs/python/agent/agent/computers/__init__.py b/libs/python/agent/agent/computers/__init__.py index 9b60308a..7c7194b6 100644 --- a/libs/python/agent/agent/computers/__init__.py +++ b/libs/python/agent/agent/computers/__init__.py @@ -6,14 +6,14 @@ computer interface types, supporting both the ComputerHandler protocol and the Computer library interface. """ -from .base import ComputerHandler +from .base import AsyncComputerHandler from .cua import cuaComputerHandler from .custom import CustomComputerHandler from computer import Computer as cuaComputer def is_agent_computer(computer): """Check if the given computer is a ComputerHandler or CUA Computer.""" - return isinstance(computer, ComputerHandler) or \ + return isinstance(computer, AsyncComputerHandler) or \ isinstance(computer, cuaComputer) or \ (isinstance(computer, dict)) #and "screenshot" in computer) @@ -30,7 +30,7 @@ async def make_computer_handler(computer): Raises: ValueError: If the computer type is not supported """ - if isinstance(computer, ComputerHandler): + if isinstance(computer, AsyncComputerHandler): return computer if isinstance(computer, cuaComputer): computer_handler = cuaComputerHandler(computer) diff --git a/libs/python/agent/agent/computers/base.py b/libs/python/agent/agent/computers/base.py index 161d9fb8..82d54057 100644 --- a/libs/python/agent/agent/computers/base.py +++ b/libs/python/agent/agent/computers/base.py @@ -6,7 +6,7 @@ from typing import Protocol, Literal, List, Dict, Any, Union, Optional, runtime_ @runtime_checkable -class ComputerHandler(Protocol): +class AsyncComputerHandler(Protocol): """Protocol defining the interface for computer interactions.""" # ==== Computer-Use-Preview Action Space ==== diff --git a/libs/python/agent/agent/computers/cua.py b/libs/python/agent/agent/computers/cua.py index 34a984df..f935be5b 100644 --- a/libs/python/agent/agent/computers/cua.py +++ b/libs/python/agent/agent/computers/cua.py @@ -4,10 +4,10 @@ Computer handler implementation for OpenAI computer-use-preview protocol. import base64 from typing import Dict, List, Any, Literal, Union, Optional -from .base import ComputerHandler +from .base import AsyncComputerHandler from computer import Computer -class cuaComputerHandler(ComputerHandler): +class cuaComputerHandler(AsyncComputerHandler): """Computer handler that implements the Computer protocol using the computer interface.""" def __init__(self, cua_computer: Computer): diff --git a/libs/python/agent/agent/computers/custom.py b/libs/python/agent/agent/computers/custom.py index 7ee027fd..b5f801b6 100644 --- a/libs/python/agent/agent/computers/custom.py +++ b/libs/python/agent/agent/computers/custom.py @@ -6,10 +6,10 @@ import base64 from typing import Dict, List, Any, Literal, Union, Optional, Callable from PIL import Image import io -from .base import ComputerHandler +from .base import AsyncComputerHandler -class CustomComputerHandler(ComputerHandler): +class CustomComputerHandler(AsyncComputerHandler): """Computer handler that implements the Computer protocol using a dictionary of custom functions.""" def __init__(self, functions: Dict[str, Callable]):