Fix cached click actions succeeding when element doesn't exist (#SKY-7577) (#4485)

This commit is contained in:
pedrohsdb
2026-01-19 09:38:17 -08:00
committed by GitHub
parent c07068581d
commit 055d585665

View File

@@ -182,7 +182,13 @@ class RealSkyvernPageAi(SkyvernPageAi):
organization_id=context.organization_id,
)
actions_json = json_response.get("actions", [])
if actions_json:
if not actions_json:
# LLM returned no actions - the element likely doesn't exist on the page.
# Raise an exception so the caller knows the action failed.
raise Exception(
f"AI could not find an element to click for intention: {intention}. "
"The element may not exist on the current page."
)
task_id = context.task_id if context else None
task = await app.DATABASE.get_task(task_id, organization_id) if task_id and organization_id else None
if organization_id and task and step:
@@ -206,6 +212,9 @@ class RealSkyvernPageAi(SkyvernPageAi):
await locator.click(timeout=timeout)
return selector
# If we reach here with no selector, the AI failed and there's no fallback - raise an error
raise Exception(f"AI click failed and no fallback selector available for intention: {intention}")
async def ai_input_text(
self,
selector: str | None,