Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Raise clear error when using Ollama models with ComputerAgent image inputs (#711)

Fizza Mukhtar8cc1adc74202
diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.py
index d3e6ede369..4d193b9094 100644
--- a/libs/python/agent/agent/agent.py
+++ b/libs/python/agent/agent/agent.py
@@ -709,6 +709,33 @@ class ComputerAgent:
**merged_kwargs,
}
+ # ---- Ollama image input guard ----
+ if isinstance(self.model, str) and ("ollama/" in self.model or "ollama_chat/" in self.model):
+ def contains_image_content(msgs):
+ for m in msgs:
+ # 1️⃣ Check regular message content
+ content = m.get("content")
+ if isinstance(content, list):
+ for item in content:
+ if isinstance(item, dict) and item.get("type") == "image_url":
+ return True
+
+ # 2️⃣ Check computer_call_output screenshots
+ if m.get("type") == "computer_call_output":
+ output = m.get("output", {})
+ if output.get("type") == "input_image" and "image_url" in output:
+ return True
+
+ return False
+
+ if contains_image_content(preprocessed_messages):
+ raise ValueError(
+ "Ollama models do not support image inputs required by ComputerAgent. "
+ "Please use a vision-capable model (e.g., OpenAI or Anthropic) "
+ "or remove computer/screenshot actions."
+ )
+ # ---------------------------------
+
# Run agent loop iteration
result = await self.agent_loop.predict_step(
**loop_kwargs,