Skip to content

Add unified CUA template with multi-provider fallback#143

Open
masnwilliams wants to merge 4 commits intomainfrom
hypeship/unified-cua-template
Open

Add unified CUA template with multi-provider fallback#143
masnwilliams wants to merge 4 commits intomainfrom
hypeship/unified-cua-template

Conversation

@masnwilliams
Copy link
Copy Markdown
Contributor

@masnwilliams masnwilliams commented Apr 8, 2026

Summary

  • Adds a new cua template (TypeScript + Python) that consolidates the separate anthropic-computer-use, openai-computer-use, and gemini-computer-use templates into a single multi-provider template
  • Provider selection via CUA_PROVIDER env var, with automatic fallback via CUA_FALLBACK_PROVIDERS
  • Each provider adapter is self-contained with full agent loop implementation
  • Shared browser session lifecycle with replay recording support
  • Registered as a new template in templates.go for both TypeScript and Python

Structure

pkg/templates/{typescript,python}/cua/
  index.ts / main.py          — Kernel app entrypoint
  session.ts / session.py     — Browser session lifecycle
  providers/
    index.ts / __init__.py    — Provider factory + fallback
    anthropic.ts / .py        — Anthropic Claude adapter
    openai.ts / .py           — OpenAI GPT adapter
    gemini.ts / .py           — Google Gemini adapter

Test plan

  • go build ./... passes
  • go test ./pkg/create/... passes
  • kernel create shows "Unified CUA" template for both TS and Python
  • Deploy TS template with Anthropic provider and run a task
  • Deploy TS template with OpenAI provider and run a task
  • Deploy TS template with Gemini provider and run a task
  • Test fallback by setting an invalid primary key with valid fallback
  • Repeat above for Python template

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes are additive (new cua templates and template registry entries) with no modifications to existing runtime logic beyond surfacing the new option in kernel create. Main risk is template correctness and provider env configuration at deploy time.

Overview
Adds a new Unified CUA template (cua) for both TypeScript and Python and registers it in pkg/create/templates.go with deploy/invoke samples.

The new templates implement a multi-provider computer-use agent that selects a primary backend via CUA_PROVIDER, optionally tries CUA_FALLBACK_PROVIDERS on failure, and supports optional browser replay recording (record_replay) via a shared session manager.

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

@kernel-internal
Copy link
Copy Markdown
Contributor

🔧 CI Fix Available
I've pushed a fix for the CI failure by adding the missing _gitignore files for the new CUA templates.

👉 Click here to create a PR with the fix

@masnwilliams masnwilliams marked this pull request as ready for review April 8, 2026 20:09
Consolidates the separate anthropic-computer-use, openai-computer-use,
and gemini-computer-use templates into a single "cua" template that
supports all three providers with automatic fallback.

- TypeScript and Python templates with identical structure
- Provider selection via CUA_PROVIDER env var
- Optional fallback chain via CUA_FALLBACK_PROVIDERS
- Shared browser session lifecycle with replay support
- Each provider adapter is self-contained and customizable
- Registered as "cua" template in templates.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@masnwilliams masnwilliams force-pushed the hypeship/unified-cua-template branch from 99891de to 73255f9 Compare April 8, 2026 20:16
<IMPORTANT>
* When using Chromium, if a startup wizard appears, IGNORE IT.
* Click on the search bar and enter the appropriate URL there.
</IMPORTANT>`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Anthropic system prompt date freezes at module load

Medium Severity

The SYSTEM_PROMPT's date is evaluated once at module load time, not per request, due to its definition as a module-level const template literal. This causes the date to become stale for long-running applications, potentially confusing the model on time-sensitive tasks. Other providers dynamically compute the date per-task.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73255f9. Configure here.

"scroll_at", "wait_5_seconds", "go_back", "go_forward",
"search", "navigate", "key_combination", "drag_and_drop",
"open_web_browser",
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Python Gemini drops screenshots, PREDEFINED_ACTIONS unused

Medium Severity

PREDEFINED_ACTIONS is defined but never referenced in the Python Gemini provider. In the TypeScript version, this list is used to conditionally include screenshot data in the functionResponse sent back to the model. The Python version captures screenshots in _execute_action but the screenshot key in the returned dict is completely ignored when constructing the FunctionResponsePart — only url is used. This is a likely incomplete port from the TypeScript implementation.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73255f9. Configure here.

"scroll_at", "wait_5_seconds", "go_back", "go_forward",
"search", "navigate", "key_combination", "drag_and_drop",
"open_web_browser",
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PREDEFINED_ACTIONS defined but never used in Python Gemini

Low Severity

PREDEFINED_ACTIONS is defined at module level but never referenced anywhere in the Python Gemini provider. The TypeScript counterpart attempts to use it when constructing function responses (to conditionally include screenshot data), but that usage is also ineffective since parts isn't a valid field on functionResponse. This appears to be leftover from an incomplete screenshot-forwarding implementation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 73255f9. Configure here.

Provider resolution at module load crashes during Hypeman's build/discovery
phase when env vars aren't available. Use lazy initialization so providers
are resolved on first invocation instead.

Also fix TS type errors: narrow candidate.content in Gemini provider, cast
input items in OpenAI provider, simplify computer_call_output construction.

Made-with: Cursor
…odel inputs

- Bump all TS and Python deps to latest versions
- Fix Anthropic computer use: use computer_20251124 with computer-use-2025-11-24
  beta flag (claude-sonnet-4-6 requires the newer tool version)
- Fix OpenAI: add missing screenshot action handler
- Fix Python: correct SDK API (kernel.App), fix session.delete call, add
  missing openai dependency
- Restore provider and model as per-request payload overrides (were dropped
  in rewrite). Provider uses a typed enum (anthropic | openai | gemini).

Made-with: Cursor
Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

There are 5 total unresolved issues (including 4 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e377d08. Configure here.

… API, session delete

- Add missing screenshot action handler in Python OpenAI provider
- Use Part.from_function_response() instead of FunctionResponsePart() in
  Python Gemini provider (pydantic extra_forbidden in google-genai >=1.71)
- Fix session cleanup: use delete_by_id() instead of delete()

Made-with: Cursor
@masnwilliams masnwilliams requested a review from dprevoznik April 8, 2026 22:14
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