Skip to content

Commit 7c204a5

Browse files
committed
fix(anthropic-cua): use 120px scroll multiplier to match Anthropic xdotool behavior
Anthropic's reference implementation uses xdotool where each scroll_amount unit equals one scroll wheel click (~120 pixels). Previously: - TypeScript used the value directly - Python used a 10x multiplier Both now use 120x to match Anthropic's expected behavior for AI agents.
1 parent 77db935 commit 7c204a5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/templates/python/anthropic-computer-use/tools/computer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ async def __call__(
370370
else:
371371
x, y = self._last_mouse_position
372372

373-
scroll_factor = scroll_amount * 10
373+
# Each scroll_amount unit = 1 scroll wheel click ≈ 120 pixels (matches Anthropic's xdotool behavior)
374+
scroll_factor = scroll_amount * 120
374375

375376
delta_x = 0
376377
delta_y = 0

pkg/templates/typescript/anthropic-computer-use/tools/computer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ export class ComputerTool implements BaseAnthropicTool {
304304

305305
let delta_x = 0;
306306
let delta_y = 0;
307-
const scrollDelta = scrollAmountValue ?? 120;
307+
// Each scroll_amount unit = 1 scroll wheel click ≈ 120 pixels (matches Anthropic's xdotool behavior)
308+
const scrollDelta = (scrollAmountValue ?? 1) * 120;
308309

309310
if (scrollDirection === 'down') {
310311
delta_y = scrollDelta;

0 commit comments

Comments
 (0)