stagehand icon indicating copy to clipboard operation
stagehand copied to clipboard

Error whenever using act()

Open Kolgann opened this issue 11 months ago • 4 comments

First of all - I'm new to stagehand, and I don't have a subscription to either OpenAI or Anthropic, so my only testing has been a local LLM with Ollama (w/ llama3.2).

I've been having a lot of success with reading information from a webpage using extract(), but I have not been able to do anything with act(). It seems like if I'm including some data (such as text) that I'm asking it to work with, like in this example:

await stagehand.page.goto("https://google.com/");
await page.act({ action: "type the text 'test' in the search field" });

I get an error like this:

 Cannot assign to read only property '0' of string '["search field"]'
 TypeError: Cannot assign to read only property '0' of string '["search field"]'
    at {my working path}\node_modules\@browserbasehq\stagehand\dist\index.js:3269:29
    at Array.forEach (<anonymous>)
    at StagehandActHandler.<anonymous> ({my working path}\node_modules\@browserbasehq\stagehand\dist\index.js:3267:26)
    at Generator.next (<anonymous>)
    at fulfilled ({my working path}\node_modules\@browserbasehq\stagehand\dist\index.js:63:24)

If it's a simple action with no data to handle, like this example:

await stagehand.page.goto("https://google.com/");
await page.act({ action: "click the `I'm Feeling Lucky` button" });

I get this instead:

 args is not iterable
 TypeError: args is not iterable
    at StagehandActHandler.<anonymous> (F:\Gannon Workspace\Tools\stagehand\ollama-test-from-template\node_modules\@browserbasehq\stagehand\dist\index.js:3265:36)
    at Generator.next (<anonymous>)
    at fulfilled (F:\Gannon Workspace\Tools\stagehand\ollama-test-from-template\node_modules\@browserbasehq\stagehand\dist\index.js:63:24)

I followed the quickstart guide and my code is basically just the custom-client-ollama example that I'm using to experiment with act(). I greatly appreciate any help, really hoping to get this working as stagehand seems like a very cool project!

Kolgann avatar Feb 05 '25 10:02 Kolgann

Ah man, sorry you're running into this issue! What model are you trying? Does it support tool calling?

kamath avatar Feb 06 '25 22:02 kamath

@kamath Thanks for the reply - I'm using llama3.2 (since that's what I saw in this example, which I'm pretty sure supports tool calling.

Kolgann avatar Feb 06 '25 23:02 Kolgann

I was able to get it to call tools using qwen2.5 but deepseek-r1, gemma2 will give an error about not supporting tools and llama3.2 just throws the args not iterable error despite Ollama's website listing (tools) as a label.

pl-shernandez avatar Feb 26 '25 20:02 pl-shernandez

First of all - I'm new to stagehand, and I don't have a subscription to either OpenAI or Anthropic, so my only testing has been a local LLM with Ollama (w/ llama3.2).

Gemini 2 flash is free. Try it with Gemini first, then if ti works with the cloud version then test if with the local version.

https://x.com/sundarpichai/status/1894447488649543735

gruckion avatar Feb 26 '25 22:02 gruckion

@gruckion I did try it with a Gemini API key and sure enough, works great. I may end up just using Gemini long-term, but I'll do some more experimenting with local LLMs (esp. qwen2.5 as suggested by @pl-shernandez) and see how it goes. Thanks

Kolgann avatar Jun 11 '25 03:06 Kolgann