Skip to content

Conversation

@tkattkat
Copy link
Collaborator

@tkattkat tkattkat commented Oct 10, 2025

why

currently, we have no sense of what url an action was taken on and what time it was taken when using agent

this is useful to have, because in the dashboard it will allow us to filter the agents actions by url, and display timestamps of the individual actions

what changed

  • added pageUrl to every action
  • added timestamp to every action

the url is grabbed prior to the action being taken. This is because if we do it after the action is taken, there is a chance the action could have caused a navigation, which would result in the incorrect url for the action

test plan

tested locally

@changeset-bot
Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: 73fba32

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

Added pageUrl field to all agent actions to track which URL each action was performed on, enabling URL-based filtering in the dashboard.

  • cuaAgentHandler.ts: Captures pageUrl immediately at the start of the action handler (line 75) before action execution to avoid capturing post-navigation URLs
  • stagehandAgentHandler.ts: Uses a currentPageUrl variable initialized at line 57, assigned to each action at line 189, then updated after tool execution at line 200
  • Both implementations correctly capture the URL before the action executes, preventing incorrect URL attribution when actions trigger navigation
  • The pageUrl field already exists in the AgentAction interface (types/agent.ts:20) with comment "ariaTree tool", but is now populated for all action types

Confidence Score: 3/5

  • This PR is relatively safe but requires a changeset file before merging
  • The logic changes are straightforward and correct - capturing URLs before actions prevents navigation-related issues. However, the PR is missing a required changeset file per repository policy, which must be added before merge.
  • No files require special attention from a code logic perspective, but a changeset file must be created in .changeset/ directory

Important Files Changed

File Analysis

Filename Score Overview
lib/handlers/cuaAgentHandler.ts 4/5 Added pageUrl to actions at line 75, capturing URL before action execution to avoid navigation issues
lib/handlers/stagehandAgentHandler.ts 4/5 Tracks pageUrl with currentPageUrl variable (line 57), assigned to actions before execution and updated after each tool call

Sequence Diagram

sequenceDiagram
    participant Agent
    participant Handler as Agent Handler
    participant Page as Browser Page
    participant Action as AgentAction

    Note over Agent,Action: cuaAgentHandler Flow
    Agent->>Handler: setActionHandler(action callback)
    Handler->>Page: page.url()
    Page-->>Handler: current URL
    Handler->>Action: action.pageUrl = url
    Handler->>Handler: executeAction(action)
    Note over Handler: Action executes (may cause navigation)
    Handler->>Page: updateClientUrl()

    Note over Agent,Action: stagehandAgentHandler Flow
    Handler->>Page: page.url()
    Page-->>Handler: initial URL
    Handler->>Handler: currentPageUrl = url
    Handler->>Agent: execute with onStepFinish
    loop For each tool call
        Handler->>Action: create AgentAction with currentPageUrl
        Note over Handler: Action executes via tool
        Handler->>Page: page.url()
        Page-->>Handler: potentially new URL
        Handler->>Handler: currentPageUrl = new url
    end
Loading

Additional Comments (1)

  1. .changeset, line 1 (link)

    logic: Missing changeset file for this PR. All code changes require a changeset to document the version bump.

    Context Used: Rule from dashboard - All PRs that make code changes must include a changeset to document the version bump and changes. (source)

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@tkattkat tkattkat changed the title add pageurl to agent actions add pageurl & timestamp to agent actions Oct 10, 2025
@tkattkat tkattkat requested a review from miguelg719 October 16, 2025 22:17
@tkattkat tkattkat merged commit f426ba5 into main Oct 16, 2025
39 of 41 checks passed
@github-actions github-actions bot mentioned this pull request Dec 5, 2025
seanmcguire12 pushed a commit that referenced this pull request Dec 5, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to v2, this PR will
be updated.


# Releases
## @browserbasehq/[email protected]

### Patch Changes

- [#1275](#1275)
[`a372b3c`](a372b3c)
Thanks [@miguelg719](https://github.com/miguelg719)! - Remove process
exit on signal handler

- [#1143](#1143)
[`fc06d40`](fc06d40)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add logger
param to external aisdk client

- [#1137](#1137)
[`2dbac99`](2dbac99)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add haiku 4.5
computer use support

- [#1116](#1116)
[`b419fc3`](b419fc3)
Thanks [@tkattkat](https://github.com/tkattkat)! - patch stagehand agent
api support

- [#1362](#1362)
[`f26333e`](f26333e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - use CDP to
find scrollable nodes instead of injected JS

- [#1125](#1125)
[`cbff109`](cbff109)
Thanks [@tkattkat](https://github.com/tkattkat)! - update cua agents key
& system prompt handling

- [#1363](#1363)
[`223e158`](223e158)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add
causedBy to StagehandDefaultError

- [#1123](#1123)
[`f426ba5`](f426ba5)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add pageUrl &
timestamp to agent actions

- [#1365](#1365)
[`2f71b02`](2f71b02)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - export
getAccessibilityTree()

- [#1366](#1366)
[`e098b0d`](e098b0d)
Thanks [@miguelg719](https://github.com/miguelg719)! - Update finding
scrollable nodes using CDP

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`a372b3c`](a372b3c),
[`fc06d40`](fc06d40),
[`2dbac99`](2dbac99),
[`b419fc3`](b419fc3),
[`f26333e`](f26333e),
[`cbff109`](cbff109),
[`223e158`](223e158),
[`f426ba5`](f426ba5),
[`2f71b02`](2f71b02),
[`e098b0d`](e098b0d)]:
    -   @browserbasehq/[email protected]

## @browserbasehq/[email protected]

### Patch Changes

- Updated dependencies
\[[`a372b3c`](a372b3c),
[`fc06d40`](fc06d40),
[`2dbac99`](2dbac99),
[`b419fc3`](b419fc3),
[`f26333e`](f26333e),
[`cbff109`](cbff109),
[`223e158`](223e158),
[`f426ba5`](f426ba5),
[`2f71b02`](2f71b02),
[`e098b0d`](e098b0d)]:
    -   @browserbasehq/[email protected]


<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Publish Stagehand 2.5.3 and bump evals (1.1.3) and examples (1.0.12).
Improves stability, CDP-based scrolling, and adds better logging and
error context.

- **New Features**
  - Haiku 4.5 computer-use support.
  - Export getAccessibilityTree().
  - Logger param for the external AISDK client.
  - Page URL and timestamp on agent actions.
  - causedBy on StagehandDefaultError for richer error context.

- **Bug Fixes**
  - Detect scrollable nodes via CDP (removed injected JS).
  - Refined CDP scrollable node detection.
  - Do not exit the process on signal handler.
  - Patch agent API support and update CUA key/system prompt handling.

<sup>Written for commit 6b62062.
Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants