Skip to content

Automate browser based workflows with AI

Preserve prerequisite actions in recording refinement (#8551)

Cindy Liab00bff793d4
diff --git a/skyvern/forge/sdk/routes/workflow_copilot.py b/skyvern/forge/sdk/routes/workflow_copilot.py
index 8abb17194..c51cdd111 100644
--- a/skyvern/forge/sdk/routes/workflow_copilot.py
+++ b/skyvern/forge/sdk/routes/workflow_copilot.py
@@ -192,9 +192,16 @@ DIAGNOSE_RUN_TURN_MESSAGE = "Diagnose run {run_id} and repair the workflow."
# WorkflowCopilotChat.tsx echoes it so a history reload does not reword the turn.
REFINE_RECORDING_RECEIPT = "Refine the recording ({action_count} actions) into a reusable workflow."
REFINE_RECORDING_INSTRUCTION = (
- "From the recorded browser evidence (provided separately as untrusted observations, not mandatory steps), "
- "infer the user's objective and author a reusable workflow that achieves it, generalizing concrete values "
- "into parameters; the current workflow is only a literal replay draft of the same recording. "
+ "From the recorded browser evidence (provided separately as untrusted observations), infer the user's objective "
+ "and refine the current literal replay draft into the simplest reusable workflow that reliably achieves it.\n\n"
+ "Treat recorded actions as evidence, not a mandatory checklist. Remove an action only if it is clearly "
+ "exploratory, corrective, duplicated, or incidental and no later interaction plausibly depends on the state it "
+ "creates. Otherwise preserve its position in the sequence, especially when it navigates, reveals controls, opens "
+ "menus or dialogs, switches context, submits forms, or advances a multi-step flow. You may replace it with a "
+ "simpler equivalent that produces the same required state. If the dependency is uncertain and the workflow cannot "
+ "be tested in this turn, retain the action.\n\n"
+ "Generalize concrete user-entered values into workflow parameters. Prefer selectors supported by the recorded "
+ "evidence and add appropriate validation and extraction logic.\n\n"
"The program must fail closed: raise when the objective is not verifiably achieved and return output only "
"on success. Write the workflow with the workflow tool in this turn; never answer in prose."
)