Skip to content

Conversation

@tkattkat
Copy link
Collaborator

why

Update example script to show benefits from using cached actions

image of what the final log looks like
image

what changed

test plan

@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2025

⚠️ No Changeset found

Latest commit: 74dfaa6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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

Greptile Summary

Refactored the CUA replay example to demonstrate cache performance benefits by executing the same task twice - first to build the cache, then to replay from cache. The script now includes performance metrics showing duration comparison, time saved, and speedup percentage between cold and cached runs.

  • Extracted logic into runDemo() function that runs twice with different cache states
  • Added performance tracking with start/end timestamps
  • Replaced drag-drop demo with login flow demo using modern login site
  • Added formatted console output showing performance comparison table
  • Imported v3Logger and dotenv for logging and environment configuration

Issue Found:

  • Typo in email address (browserbaser.com instead of browserbase.com)

Confidence Score: 4/5

  • Safe to merge after fixing the email typo - this is an example script demonstrating cache functionality
  • Minor syntax error (typo) that needs correction but doesn't affect the core demonstration logic. The refactoring improves the example by clearly showing cache benefits with performance metrics.
  • packages/core/examples/v3/cuaReplay.ts - fix email typo on line 36

Important Files Changed

File Analysis

Filename Score Overview
packages/core/examples/v3/cuaReplay.ts 4/5 Refactored example to demonstrate CUA cache performance by running two passes and comparing execution times. Contains typo in email address that should be fixed.

Sequence Diagram

sequenceDiagram
    participant User
    participant Main
    participant RunDemo1 as runDemo(1)
    participant V3_1 as V3 Instance 1
    participant Agent1 as Agent (CUA)
    participant Cache
    participant RunDemo2 as runDemo(2)
    participant V3_2 as V3 Instance 2
    participant Agent2 as Agent (CUA)

    User->>Main: Execute main()
    Main->>RunDemo1: await runDemo(1)
    RunDemo1->>V3_1: new V3({ cacheDir: "cua-agent-cache" })
    RunDemo1->>V3_1: init()
    V3_1->>RunDemo1: Browser context ready
    RunDemo1->>Agent1: agent({ cua: true })
    RunDemo1->>Agent1: execute(instruction)
    Agent1->>Cache: Write actions (BUILDING CACHE)
    Agent1->>RunDemo1: Result + duration
    RunDemo1->>Main: metrics1 (cold run)
    
    Main->>Main: Wait 2 seconds
    Main->>RunDemo2: await runDemo(2)
    RunDemo2->>V3_2: new V3({ cacheDir: "cua-agent-cache" })
    RunDemo2->>V3_2: init()
    V3_2->>RunDemo2: Browser context ready
    RunDemo2->>Agent2: agent({ cua: true })
    RunDemo2->>Agent2: execute(instruction)
    Agent2->>Cache: Read cached actions (USING CACHE)
    Cache->>Agent2: Replay actions (no LLM calls)
    Agent2->>RunDemo2: Result + duration
    RunDemo2->>Main: metrics2 (cached run)
    
    Main->>User: Performance comparison table
Loading

1 file reviewed, 1 comment

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.

2 participants