Skip to content

fix: predict_click returns None for zero coordinates (x=0 or y=0) #1400

@kuishou68

Description

@kuishou68

Bug Report

Description

In libs/python/agent/cua_agent/loops/anthropic.py, the predict_click method uses a truthiness check to validate the returned click coordinates:

if action.get("x") and action.get("y"):
    x = action.get("x")
    y = action.get("y")
    return (int(x), int(y))

This check silently fails when either coordinate is 0, because 0 is falsy in Python. For example, if the model predicts a click at (0, 300) (left edge) or (500, 0) (top edge), the condition evaluates to False, and the method incorrectly returns None instead of the valid coordinates.

Steps to Reproduce

  1. Use predict_click with a model that predicts a click at the left or top edge of the screen (x=0 or y=0).
  2. The method returns None even though the model returned valid coordinates.

Expected Behavior

Coordinates of 0 are valid — predict_click should return (0, y) or (x, 0) correctly.

Fix

Replace the truthiness check with an explicit None check:

if action.get("x") is not None and action.get("y") is not None:
    x = action.get("x")
    y = action.get("y")
    return (int(x), int(y))

Impact

Any use case where the model must click an element at the leftmost column or topmost row of the screen will silently fail and return None.

Signed-off-by: cocoon 54054995+kuishou68@users.noreply.github.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions