stagehand icon indicating copy to clipboard operation
stagehand copied to clipboard

stagehand.act interacts with stagehand-nav components

Open dncnbuck opened this issue 11 months ago • 1 comments

I updated from stagehand version 1.3 to 1.6 so I could remove the debug dom elements without having to run manual cleanup

Note: they still are present in my session with debugDom: false image

It seems like the system prompts update (https://github.com/browserbase/stagehand/blob/main/lib/prompt.ts#L22)

For me this has caused the agent to now attempt to resolve actions by clicking these debugDom elements. Which ends up in an endless loop where it clicks the button and clicks it again. (Note I downgraded to 1.3 and this behaviour is not seen) Heres a small snippet of the log for a acting on a url https://zip.co/us with action=close any popups, banners, terms and conditions that are present when you navigate to the homepage.

[stagehand:action] received response from LLM {"response":{"value":"{\"method\":\"click\",\"element\":0,\"args\":[],\"step\":\"Clicked on the 'Next' button to potentially close a popup or navigate through a carousel.\",\"why\":\"This button might be part of a popup or carousel that needs to be closed or navigated through to access the main content.\",\"completed\":false}","type":"object"}}
[stagehand:action] executing method {"method":{"value":"click","type":"string"},"elementId":{"value":"0","type":"integer"},"xpaths":{"value":"[\"/html/body[1]/button[2]\",\"//html/body/button[2]\"]","type":"object"},"args":{"value":"[]","type":"object"}}
[stagehand:action] page URL before action {"url":{"value":"https://zip.co/us","type":"string"}}

I quick fix is to tell the agent to never click on selectors with classname = 'stagehand-nav', but I think a change in the system prompt might be a more long term change, for example

Note 3: A step action to accomplish the user's goal will never be successful if stagehand-nav elements  are clicked

dncnbuck avatar Dec 13 '24 05:12 dncnbuck

Thanks so much for making this a GitHub issue! @seanmcguire12 pointed this out internally when running evals. Appreciate the detailed write-up, but idk if a system-prompt is going to help here. We should probably just deprecate/remove stagehand nav; I don't personally find it very useful, and it's clearly causing some bugs.

kamath avatar Dec 13 '24 05:12 kamath

Fixed in #360

kamath avatar Jan 03 '25 20:01 kamath