Skip to content

[Bug Report]: rounding error leads to incorrect clicks #1730

@sthoduka

Description

@sthoduka

Version

@ui-tars/action-parser 1.2.3

Issue Type

  • Select a issue type 👇
  • Agent TARS Web UI (@agent-tars/web-ui)
  • Agent TARS CLI (@agent-tars/server)
  • Agent TARS Server (@agent-tars/server)
  • Agent TARS (@agent-tars/core)
  • MCP Agent (@tarko/mcp-agent)
  • Agent Kernel (@tarko/agent)
  • Other (please specify in description)

Model Provider

  • Select a model provider 👇
  • Volcengine
  • Anthropic
  • OpenAI
  • Azure OpenAI
  • Other (please specify in description)

Problem Description

The function smartResizeForV15 returns different results for some sizes compared to the smart_resize function in the Python library, which is also the same function used in the model processor.

The reason is that Javascript performs rounding differently to Python.
Javascript rounds X.5 -> (X+1)
Python rounds X.5 -> (X) if X is even, and (X+1) if X is odd.

Python:

smart_resize(1022, 1522) -> (1008, 1512)

Javascript

smartResizeForV15(1022, 1522) -> (1512, 1036)

In the above example, the difference in h_bar (1008 vs 1036) is enough to miss click coordinates, especially towards the bottom of the page.

Suggested fix: implement own rounding function that behaves like Python. I'm happy to send a PR if that sounds reasonable.

Error Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions