-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add pageurl & timestamp to agent actions #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest 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 |
There was a problem hiding this 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 theAgentAction
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
Additional Comments (1)
2 files reviewed, 1 comment
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
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