Skip to content

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

Open
kuishou68 wants to merge 1 commit into
trycua:mainfrom
kuishou68:fix/issue-1400-predict-click-zero-coords
Open

fix: predict_click returns None for zero coordinates (x=0 or y=0)#1401
kuishou68 wants to merge 1 commit into
trycua:mainfrom
kuishou68:fix/issue-1400-predict-click-zero-coords

Conversation

@kuishou68
Copy link
Copy Markdown

@kuishou68 kuishou68 commented Apr 27, 2026

Summary

Fixes a bug in AnthropicHostedToolsConfig.predict_click where coordinates with a value of 0 were silently discarded due to a Python truthiness check.

Problem

# BEFORE (buggy): 0 is falsy, so clicks at left/top edge return None
if action.get("x") and action.get("y"):

When a model predicts a click at the leftmost column (x=0) or topmost row (y=0) of the screen, 0 evaluates as falsy in Python, causing the condition to fail and the method to return None instead of the valid (0, y) or (x, 0) coordinates.

Fix

# AFTER (correct): explicitly check for None
if action.get("x") is not None and action.get("y") is not None:

This correctly treats 0 as a valid coordinate value while still guarding against missing keys.

Files Changed

  • libs/python/agent/cua_agent/loops/anthropic.py — line 1950: replace truthiness check with is not None

Closes #1400

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed coordinate validation to correctly accept click positions at the top-left corner (0,0), resolving issues where such interactions were being incorrectly rejected.

…ua#1400)

Zero coordinates (x=0 or y=0) are valid click positions but were being
treated as falsy in the truthiness check. Replace with explicit None check.

Signed-off-by: cocoon <54054995+kuishou68@users.noreply.github.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 27, 2026

@kuishou68 is attempting to deploy a commit to the Cua Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 805d5c34-59d4-46c3-a4c4-a6f94d026bee

📥 Commits

Reviewing files that changed from the base of the PR and between 31a64eb and 7adc2ac.

📒 Files selected for processing (1)
  • libs/python/agent/cua_agent/loops/anthropic.py

📝 Walkthrough

Walkthrough

The predict_click method now validates click coordinates using explicit None checks instead of truthiness evaluation, ensuring zero values for x or y coordinates are accepted as valid rather than rejected.

Changes

Cohort / File(s) Summary
Coordinate Validation Fix
libs/python/agent/cua_agent/loops/anthropic.py
Changed coordinate validation from truthiness check to explicit None check, allowing valid zero coordinates (x=0 or y=0) to be processed correctly instead of being silently rejected.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A click at the edge was once lost,
When zero made conditions crossed,
But now with is not None so true,
The leftmost corner clicks right through! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: fixing predict_click to handle zero coordinates correctly by replacing a truthiness check with explicit None checks.
Linked Issues check ✅ Passed The PR directly addresses issue #1400 by implementing the exact fix specified: replacing truthiness check with explicit None checks to allow zero-valued coordinates.
Out of Scope Changes check ✅ Passed The changes are limited to the specific bug fix in predict_click with a single line change (+1/-1), staying within the scope defined by issue #1400.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant