Skip to content

Conversation

@tkattkat
Copy link
Collaborator

@tkattkat tkattkat commented Oct 10, 2025

why

currently, for openai cua agent, we are handling keypress actions incorrectly
currently, there is no way to pass a custom system prompt to the Google cua agent

what changed

  • All key actions, are now ran through mapKeyToPlaywright function to ensure we are properly mapping the agents actions to valid playwright keys
  • Custom system prompts now override the default system prompt for Google Cua agent

test plan

tested locally with google & openai cua agents

Fixes #1122

@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: a63a9f6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

Fixed key action handling for OpenAI CUA agent and enabled custom system prompt support for Google CUA agent.

Key Changes:

  • All key actions in keypress handlers now properly map keys through mapKeyToPlaywright function to ensure compatibility with Playwright
  • Google CUA agent now respects custom system prompts passed via userProvidedInstructions, overriding the default system prompt
  • Proper changeset included for version tracking

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-scoped bug fixes that improve key action handling and add missing functionality for custom system prompts. The mapKeyToPlaywright utility function already exists and is being used elsewhere in the codebase. The system prompt change simply adds conditional logic to use custom instructions when provided. All changes include proper changeset documentation.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
lib/agent/GoogleCUAClient.ts 5/5 Updated system prompt handling to use custom instructions when provided, falling back to default prompt
lib/handlers/cuaAgentHandler.ts 5/5 Fixed keypress handling by mapping keys through mapKeyToPlaywright function before sending to Playwright

Sequence Diagram

sequenceDiagram
    participant Agent as CUA Agent
    participant Handler as CuaAgentHandler
    participant Mapper as mapKeyToPlaywright
    participant Page as Playwright Page

    Agent->>Handler: keypress action with keys array
    Handler->>Mapper: map each key (e.g., "ENTER")
    Mapper-->>Handler: return Playwright key (e.g., "Enter")
    Handler->>Handler: join mapped keys with "+"
    Handler->>Page: keyboard.press(mappedKeys)
    
    Note over Agent,Handler: Google CUA Client System Prompt
    Agent->>Agent: initializeHistory(instruction)
    alt userProvidedInstructions exists
        Agent->>Agent: use userProvidedInstructions
    else no custom instructions
        Agent->>Agent: use buildGoogleCUASystemPrompt().content
    end
    Agent->>Agent: add system prompt to history
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

Computer Use Agent: Critical failures - invalid keys, crashes, false success reports

3 participants