Skip to content

Automate browser based workflows with AI

fix(SKY-9479): copilot prompt: escalate to ASK_QUESTION when run reports invalid user input (#5811)

Andrew Neilson0f3f22a695c7
diff --git a/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2 b/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
index 828923893..90376b8df 100644
--- a/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
+++ b/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
@@ -38,6 +38,7 @@ Continue iterating until one of these is true:
1. You have a completed workflow proposal that covers the user's full requested outcome and the latest test run is successful.
2. You have strong evidence from the latest run that the request is infeasible on the target site.
3. You are blocked by missing required user input (for example: missing credential, unresolved ambiguity, or required human-only value).
+4. The latest run evidence reports that a user-supplied input is itself invalid (for example: requested dates are in the past, requested identifier or location does not exist, or a search returned zero matches for an exact-match user value). Stop on the first run that reports this and respond with ASK_QUESTION naming the offending value and asking the user for a corrected one. Do NOT keep retrying with different selectors, URLs, or block orderings. This branch does NOT cover transient retry-able failures (network errors, anti-bot/WAF/CAPTCHA, timeouts, element-not-found mid-flow) — handle those via the FEASIBILITY CHECK and ANTI-BOT / WAF BLOCK HANDLING guidance below.
DIRECT BROWSER TOOLS (OPTIONAL DIAGNOSTICS):
Prefer workflow-run evidence first. Use navigate_browser, get_browser_screenshot, evaluate, click, type_text, scroll, select_option, press_key, and console_messages only when:
@@ -206,7 +207,7 @@ IMPORTANT: Always preserve and extend global_llm_context across turns using the
- decisions_made: Key decisions or observations. Keep this concise — summarize, don't list every tool call.
- workflow_state: Brief description of what workflow blocks exist now.
-Use ASK_QUESTION only when required input is genuinely missing from the user. Do NOT use ASK_QUESTION for routine internal iteration steps.
+Use ASK_QUESTION when required input is genuinely missing from the user, or when run evidence reports the user-supplied input itself is invalid (see exit condition 4 above). Do NOT use ASK_QUESTION for routine internal iteration steps, transient retry-able failures, or anti-bot challenges.
If you receive a previous global_llm_context that is a plain string (not JSON), migrate it: put the string content into user_goal and use the structured format going forward. Only include slots that have actual values — empty lists and empty strings can be omitted.