Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
Document api_key and api_base kwarg, rename **kwargs to **additional_generation_kwargs for clarity
Dillon DuPonta19ae76a5892
diff --git a/docs/content/docs/agent-sdk/agent-loops.mdx b/docs/content/docs/agent-sdk/agent-loops.mdxindex 08dcf07b91..57765b18cd 100644--- a/docs/content/docs/agent-sdk/agent-loops.mdx+++ b/docs/content/docs/agent-sdk/agent-loops.mdx@@ -3,7 +3,13 @@ title: Agent Loopsdescription: Supported computer-using agent loops and models----<Callout>A corresponding <a href="https://github.com/trycua/cua/blob/main/notebooks/agent_nb.ipynb" target="_blank">Jupyter Notebook</a> is available for this documentation.</Callout>+<Callout>+ A corresponding{' '}+ <a href="https://github.com/trycua/cua/blob/main/notebooks/agent_nb.ipynb" target="_blank">+ Jupyter Notebook+ </a>{' '}+ is available for this documentation.+</Callout>An agent can be thought of as a loop - it generates actions, executes them, and repeats until done:@@ -102,7 +108,7 @@ messages = ["content": "Take a screenshot and describe what you see"},{- "role": "assistant",+ "role": "assistant","content": "I'll take a screenshot for you."}]@@ -138,7 +144,11 @@ The `ComputerAgent` constructor provides a wide range of options for customizingIf set (float or dict), adds a budget manager callback that tracks usage costs and stops execution if the budget is exceeded. Dict allows advanced options (e.g., `{ "max_budget": 5.0, "raise_error": True }`).- `instructions` (`str` | `list[str]`):System instructions for the agent. Can be a single string or multiple strings in a tuple/list for readability; they are concatenated into one system prompt.-- `**kwargs` (`any`):+- `api_key` (`str`):+ Optional API key override for the model provider.+- `api_base` (`str`):+ Optional API base URL override for the model provider.+- `**additional_generation_kwargs` (`any`):Any additional keyword arguments are passed through to the agent loop or model provider.**Example with advanced options:**@@ -162,7 +172,9 @@ agent = ComputerAgent(instructions=("You are a helpful computer-using agent""Output computer calls until you complete the given task"- )+ ),+ api_key="your-api-key",+ api_base="https://your-api-base.com/v1",)```diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.pyindex b01b19455e..f85c513cde 100644--- a/libs/python/agent/agent/agent.py+++ b/libs/python/agent/agent/agent.py@@ -187,7 +187,7 @@ class ComputerAgent:trust_remote_code: Optional[bool] = False,api_key: Optional[str] = None,api_base: Optional[str] = None,- **kwargs,+ **additional_generation_kwargs,):"""Initialize ComputerAgent.@@ -207,7 +207,9 @@ class ComputerAgent:max_trajectory_budget: If set, adds BudgetManagerCallback to track usage costs and stop when budget is exceededtelemetry_enabled: If set, adds TelemetryCallback to track anonymized usage data. Enabled by default.trust_remote_code: If set, trust remote code when loading local models. Disabled by default.- **kwargs: Additional arguments passed to the agent loop+ api_key: Optional API key override for the model provider+ api_base: Optional API base URL override for the model provider+ **additional_generation_kwargs: Additional arguments passed to the model provider"""# If the loop is "human/human", we need to prefix a grounding model fallbackif model in ["human/human", "human"]:@@ -225,7 +227,7 @@ class ComputerAgent:self.screenshot_delay = screenshot_delayself.use_prompt_caching = use_prompt_cachingself.telemetry_enabled = telemetry_enabled- self.kwargs = kwargs+ self.kwargs = additional_generation_kwargsself.trust_remote_code = trust_remote_codeself.api_key = api_keyself.api_base = api_base@@ -597,7 +599,12 @@ class ComputerAgent:# ============================================================================async def run(- self, messages: Messages, stream: bool = False, api_key: Optional[str] = None, api_base: Optional[str] = None, **kwargs+ self,+ messages: Messages,+ stream: bool = False,+ api_key: Optional[str] = None,+ api_base: Optional[str] = None,+ **additional_generation_kwargs,) -> AsyncGenerator[Dict[str, Any], None]:"""Run the agent with the given messages using Computer protocol handler pattern.@@ -605,7 +612,9 @@ class ComputerAgent:Args:messages: List of message dictionariesstream: Whether to stream the response- **kwargs: Additional arguments+ api_key: Optional API key override for the model provider+ api_base: Optional API base URL override for the model provider+ **additional_generation_kwargs: Additional arguments passed to the model providerReturns:AsyncGenerator that yields response chunks@@ -622,7 +631,7 @@ class ComputerAgent:await self._initialize_computers()# Merge kwargs and thread api credentials (run overrides constructor)- merged_kwargs = {**self.kwargs, **kwargs}+ merged_kwargs = {**self.kwargs, **additional_generation_kwargs}if (api_key is not None) or (self.api_key is not None):merged_kwargs["api_key"] = api_key if api_key is not None else self.api_keyif (api_base is not None) or (self.api_base is not None):diff --git a/libs/python/agent/agent/loops/base.py b/libs/python/agent/agent/loops/base.pyindex 751fae7587..ed73de44d2 100644--- a/libs/python/agent/agent/loops/base.py+++ b/libs/python/agent/agent/loops/base.py@@ -24,7 +24,7 @@ class AsyncAgentConfig(Protocol):_on_api_end=None,_on_usage=None,_on_screenshot=None,- **generation_kwargs,+ **generation_config,) -> Dict[str, Any]:"""Predict the next step based on input items.@@ -40,7 +40,7 @@ class AsyncAgentConfig(Protocol):_on_api_end: Callback for API end_on_usage: Callback for usage tracking_on_screenshot: Callback for screenshot events- **generation_kwargs: Additional arguments for generation+ **generation_config: Additional arguments to pass to the model provider- api_key: Optional API key for the provider- api_base: Optional API base URL for the provider@@ -60,6 +60,9 @@ class AsyncAgentConfig(Protocol):model: Model name to useimage_b64: Base64 encoded imageinstruction: Instruction for where to click+ **generation_config: Additional arguments to pass to the model provider+ - api_key: Optional API key for the provider+ - api_base: Optional API base URL for the providerReturns:None or tuple with (x, y) coordinates