{"record":{"id":"2ddafadc8872d828","repo":"FoundationAgents/MetaGPT","slug":"invalid-goto-action-step","errorCode":null,"errorMessage":"Invalid goto action {step}","messagePattern":"Invalid goto action (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/utils/a11y_tree.py","lineNumber":73,"sourceCode":"        await click_element(page, get_backend_node_id(element_id, accessibility_tree))\n        await type_text(page, text)\n    elif func == \"press\":\n        match = re.search(r\"press ?\\[(.+)\\]\", step)\n        if not match:\n            raise ValueError(f\"Invalid press action {step}\")\n        key = match.group(1)\n        await key_press(page, key)\n    elif func == \"scroll\":\n        # up or down\n        match = re.search(r\"scroll ?\\[?(up|down)\\]?\", step)\n        if not match:\n            raise ValueError(f\"Invalid scroll action {step}\")\n        direction = match.group(1)\n        await scroll_page(page, direction)\n    elif func == \"goto\":\n        match = re.search(r\"goto ?\\[(.+)\\]\", step)\n        if not match:\n            raise ValueError(f\"Invalid goto action {step}\")\n        url = match.group(1)\n        await page.goto(url)\n    elif func == \"new_tab\":\n        page = await browser_ctx.new_page()\n    elif func == \"go_back\":\n        await page.go_back()\n    elif func == \"go_forward\":\n        await page.go_forward()\n    elif func == \"tab_focus\":\n        match = re.search(r\"tab_focus ?\\[(\\d+)\\]\", step)\n        if not match:\n            raise ValueError(f\"Invalid tab_focus action {step}\")\n        page_number = int(match.group(1))\n        page = browser_ctx.pages[page_number]\n        await page.bring_to_front()\n    elif func == \"close_tab\":\n        await page.close()\n        if len(browser_ctx.pages) > 0:","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/utils/a11y_tree.py#L55-L91","documentation":"MetaGPT's execute_action raises this when a step classified as goto fails to match r'goto ?\\[(.+)\\]'. The expected format is 'goto [https://example.com]'; any deviation (missing brackets, empty URL) makes the regex search return None.","triggerScenarios":"execute_action(page, 'goto https://example.com') without brackets; 'goto []' with empty URL; 'goto (https://example.com)' with parentheses; unbalanced brackets from LLM markdown formatting.","commonSituations":"LLM emits a bare URL or wraps it in parentheses/quotes instead of square brackets. Also occurs when URL text contains ']' early, truncating the capture, or when the step extraction (extract_step) clipped the closing bracket.","solutions":["Reformat the step as 'goto [https://example.com]' with square brackets.","Inspect the full LLM response to see whether the closing bracket was lost in extraction.","Strengthen the prompt's action-format examples for goto.","Validate the step with re.search(r'goto ?\\[(.+)\\]', step) before dispatching."],"exampleFix":"# before\nawait execute_action(page, 'goto https://example.com')  # raises Invalid goto action\n\n# after\nawait execute_action(page, 'goto [https://example.com]')","handlingStrategy":"validation","validationCode":"import re\n\ndef is_valid_goto(step: str) -> bool:\n    return bool(re.search(r\"goto ?\\[(.+)\\]\", step))","typeGuard":null,"tryCatchPattern":"try:\n    await execute_action(page, step)\nexcept ValueError as e:\n    if 'Invalid goto action' in str(e):\n        # re-extract URL and reformat as goto [<url>]","preventionTips":["Show goto [https://...] examples in the action prompt.","If extraction may clip brackets, validate the whole fenced step before parsing."],"tags":["metagpt","browser-agent","llm-output","regex","navigation"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}