Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions libs/python/agent/agent/loops/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def _map_gemini_fc_to_computer_call(
action = {"type": "playwright_exec", "command": "visit_url", "params": {"url": url}}
else:
return None
elif name == "open_web_browser":
elif name in ("open_web_browser", "open_browser"):
# Open browser with blank page or google
action = {
"type": "playwright_exec",
Expand Down Expand Up @@ -837,7 +837,9 @@ async def predict_step(

# Debug: print raw function calls from response
try:
for p in response.candidates[0].content.parts:
_dbg_candidates = getattr(response, "candidates", None) or []
_dbg_parts = getattr(getattr(_dbg_candidates[0] if _dbg_candidates else None, "content", None), "parts", None) or []
for p in _dbg_parts:
Comment thread
ddupont808 marked this conversation as resolved.
Resolved
if hasattr(p, "function_call") and p.function_call:
print(
f"[DEBUG] Raw function_call from model: name={p.function_call.name}, args={dict(p.function_call.args or {})}"
Expand Down Expand Up @@ -876,11 +878,16 @@ async def predict_step(
# Parse output into internal items
output_items: List[Dict[str, Any]] = []

candidate = response.candidates[0]
candidates = getattr(response, "candidates", None) or []
if not candidates:
return {"output": output_items, "usage": usage}

candidate = candidates[0]
# Text parts from the model (assistant message)
text_parts: List[str] = []
function_calls: List[Dict[str, Any]] = []
for p in candidate.content.parts:
parts = getattr(getattr(candidate, "content", None), "parts", None) or []
for p in parts:
# Check for thinking/reasoning content first
if getattr(p, "thought", False) and getattr(p, "text", None):
output_items.append(make_reasoning_item(p.text))
Expand Down
12 changes: 10 additions & 2 deletions libs/python/cua-cli/cua_cli/commands/do.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def _fail(msg: str) -> int:
return 1


class _PtyUnavailable(Exception):
"""Raised when the remote PTY endpoint is unreachable; triggers run_command fallback."""


# ── provider / connection helpers ─────────────────────────────────────────────


Expand Down Expand Up @@ -1313,7 +1317,7 @@ async def _shell_remote_pty(
resp.raise_for_status()
data = await resp.json()
except Exception as e:
return _fail(f"Failed to create PTY session: {e}")
raise _PtyUnavailable(str(e)) from e

pid: int = data["pid"]

Expand Down Expand Up @@ -1457,7 +1461,11 @@ def _cmd_shell(args: argparse.Namespace) -> int:

from cua_cli.utils.async_utils import run_async

return run_async(_shell_remote_pty(provider, name, command, cols=cols, rows=rows))
try:
return run_async(_shell_remote_pty(provider, name, command, cols=cols, rows=rows))
except _PtyUnavailable as e:
print(f"⚠️ PTY unavailable ({e}), falling back to run_command", file=sys.stderr)
return _cmd_shell_noninteractive(command, args)
Comment thread
ddupont808 marked this conversation as resolved.
Resolved


def _cmd_open(args: argparse.Namespace) -> int:
Expand Down
Loading