Skip to content

Test and harden batch_computer_actions across providers - #3

Merged
rgarcia merged 5 commits into
mainfrom
hypeship/batch-tool-tests-and-fixes
May 12, 2026
Merged

Test and harden batch_computer_actions across providers#3
rgarcia merged 5 commits into
mainfrom
hypeship/batch-tool-tests-and-fixes

Conversation

@rgarcia

@rgarcia rgarcia commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds provider-by-provider unit coverage for the batch_computer_actions schemas exposed by each createComputerToolDefinitions() (every CUA action present, narrowing preserves order, single-action mode emits a non-union schema, navigation tool is dropped when actions are narrowed, etc.).
  • Adds an env-gated integration test that hits each provider live with the example screenshot and asserts the response contains a parsed batch_computer_actions call with valid coordinates inside the declared coordinate range.
  • Tzafon fixes: the provider was returning arguments.actions as a JSON-encoded string (the API double-encodes nested arrays) and the usage counters were hard-coded to zero even though the response includes usage.input_tokens / output_tokens / total_tokens. Both are now parsed.
  • Yutori translation: Yutori's server-side model always emits its native left_click / scroll / key_press / mouse_move / etc. shape regardless of which tools the caller declares. When the caller passes batch_computer_actions, the provider now translates the native call(s) into a single canonical batch call so consumers see uniform output across all five providers.

Test plan

  • npx vitest --run (31 unit tests pass)
  • Integration tests with OPENAI_API_KEY, ANTHROPIC_API_KEY, TZAFON_API_KEY, YUTORI_API_KEY (5 pass, gemini skipped — no key on hand)

🤖 Generated with Claude Code


Note

Medium Risk
Touches provider response parsing/normalization for tzafon and yutori, which can change downstream tool-call/usage behavior across integrations; changes are mitigated by added unit and live integration coverage.

Overview
Adds a GitHub Actions CI workflow that builds @onkernel/cua-ai, runs a focused unit suite, and (when secrets are available) runs env-gated live integration tests.

Hardens batch_computer_actions end-to-end: createCuaActionSchema now emits a single-variant schema when narrowed to one action (instead of a union), and unit tests expand to validate schema coverage, strictness (additionalProperties: false), ordering, and navigation-tool omission when actions are narrowed.

Fixes provider output normalization: tzafon now reports responseId/token usage and unwraps nested JSON-encoded tool arguments, and yutori can translate its native per-action tool calls into a single canonical batch_computer_actions call when that tool is requested. A new batch-tool.integration.test.ts validates parsed batch actions and coordinate ranges across providers and probes whether multi-step tasks actually batch into one call.

Reviewed by Cursor Bugbot for commit 14e6446. Bugbot is set up for automated code reviews on this repo. Configure here.

rgarcia and others added 5 commits May 12, 2026 13:36
- Add provider-by-provider unit coverage for the batch tool schemas.
- Add integration tests (env-gated) that hit each provider live and
  verify the response contains a parsed batch_computer_actions call.
- Tzafon: unwrap stringified nested arrays in tool args and surface
  the usage counts the API already returns.
- Yutori: when callers pass batch_computer_actions, translate the
  model's native left_click/scroll/etc. calls into a canonical batch
  call so consumers get uniform output across providers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…preview

The gemini-2.5-computer-use-preview-10-2025 model rejects standard
function declarations — it requires Google's special tools.computer_use
wrapper, which packages/ai doesn't currently send. The gemini-3-flash-preview
preview, which the cua-cli README already recommends, accepts the
batch_computer_actions tool directly.

CI runs unit tests on every push/PR and runs the integration suite
when secrets are available (skipped automatically for fork PRs).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
For each provider, assert whether a click+type sequence ends up packed
into a single batch_computer_actions call. Findings encoded in the
suite:

- openai, anthropic, gemini, tzafon: pack both actions into one batch
- yutori: server-side model emits exactly one tool call per response,
  so the translated batch always carries a single action

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rgarcia
rgarcia marked this pull request as ready for review May 12, 2026 14:55
@firetiger-agent

Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: PR modifies provider schemas and tool definitions, not kernel API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal).

To monitor this PR anyway, reply with @firetiger monitor this.

@rgarcia
rgarcia force-pushed the hypeship/batch-tool-tests-and-fixes branch from fb748e1 to fdf6346 Compare May 12, 2026 14:59

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Native type action missing from Yutori batch translation
    • Added missing Yutori canonical mappings for type (plus goto_url, mouse_down, and mouse_up) so native calls now translate into batch_computer_actions actions instead of falling through.

Create PR

Or push these changes by commenting:

@cursor push 50af108f03
Preview (50af108f03)
diff --git a/packages/ai/src/providers/yutori/provider.ts b/packages/ai/src/providers/yutori/provider.ts
--- a/packages/ai/src/providers/yutori/provider.ts
+++ b/packages/ai/src/providers/yutori/provider.ts
@@ -255,6 +255,14 @@
 			return coords ? [{ type: "double_click", x: coords.x, y: coords.y }] : undefined;
 		case "mouse_move":
 			return coords ? [{ type: "move", x: coords.x, y: coords.y }] : undefined;
+		case "mouse_down":
+			return coords ? [{ type: "mouse_down", x: coords.x, y: coords.y }] : undefined;
+		case "mouse_up":
+			return coords ? [{ type: "mouse_up", x: coords.x, y: coords.y }] : undefined;
+		case "type": {
+			const text = typeof args.text === "string" ? args.text : undefined;
+			return text !== undefined ? [{ type: "type", text }] : undefined;
+		}
 		case "key_press": {
 			const key = typeof args.key === "string" ? args.key : undefined;
 			return key ? [{ type: "keypress", keys: [key] }] : undefined;
@@ -279,6 +287,10 @@
 			return [{ type: "back" }];
 		case "go_forward":
 			return [{ type: "forward" }];
+		case "goto_url": {
+			const url = typeof args.url === "string" ? args.url : undefined;
+			return url ? [{ type: "goto", url }] : undefined;
+		}
 		default:
 			return undefined;
 	}

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit fdf6346. Configure here.

Comment thread packages/ai/src/providers/yutori/provider.ts
@rgarcia
rgarcia merged commit 3135a5d into main May 12, 2026
3 checks passed
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.

1 participant