Skip to content

Automate browser based workflows with AI

A2A agent dcr oauth binding (#8739)

Shuchang Zheng92e763633790
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.json
index e4fc9b113..10b3347b2 100644
--- a/docs/api-reference/openapi.json
+++ b/docs/api-reference/openapi.json
@@ -579,15 +579,15 @@
"code-samples": [
{
"sdk": "curl",
- "code": "curl -X POST https://api.skyvern.com/v1/workflows --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: text/plain' --data-raw 'title: Contact Forms\ndescription: Fill the contact form on the website\nproxy_location: RESIDENTIAL\nwebhook_callback_url: https://example.com/webhook\ntotp_verification_url: https://example.com/totp\npersist_browser_session: false\nmodel:\n name: gpt-4.1\nworkflow_definition:\n parameters:\n - key: website_url\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: name\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: additional_information\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: |-\n Message: I'd love to learn more about your...\n Phone: 123-456-7890\n Inquiry type: sales\n Optional Subject: Hello from [Company Here]\n - key: email\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n blocks:\n - label: Fill_Out_Contact_Form\n continue_on_failure: true\n block_type: navigation\n url: \"{{website_url}}\"\n title: Fill_Out_Contact_Form\n engine: skyvern-1.0\n navigation_goal: >-\n Find the contact form. Fill out the contact us form and submit it. Your\n goal is complete when the page says your message has been sent. In the\n case you can't find a contact us form, terminate.\n\n\n Fill out required fields as best you can using the following\n information:\n\n {{name}}\n\n {{email}}\n\n {{additional_information}}\n error_code_mapping: null\n max_retries: 0\n max_steps_per_run: null\n complete_on_download: false\n download_suffix: null\n parameter_keys: []\n totp_identifier: null\n totp_verification_url: null\n complete_criterion: \"\"\n terminate_criterion: \"\"\n include_action_history_in_verification: false\n - label: Extract_Email\n continue_on_failure: false\n block_type: extraction\n url: \"\"\n title: Extract_Email\n data_extraction_goal: \"Extract a company email if available \"\n data_schema: null\n max_retries: 0\n max_steps_per_run: null\n parameter_keys: []\n'\n"
+ "code": "curl -X POST https://api.skyvern.com/v1/workflows --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: text/plain' --data-raw 'title: Contact Forms\ndescription: Fill the contact form on the website\nproxy_location: RESIDENTIAL\nwebhook_callback_url: https://example.com/webhook\ntotp_verification_url: https://example.com/totp\npersist_browser_session: false\nmodel:\n name: gpt-4.1\nworkflow_definition:\n parameters:\n - key: website_url\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: name\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: additional_information\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: |-\n Message: I'd love to learn more about your...\n Phone: 123-456-7890\n Inquiry type: sales\n Optional Subject: Hello from [Company Here]\n - key: email\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n blocks:\n - label: Fill_Out_Contact_Form\n continue_on_failure: true\n block_type: navigation\n url: \"{{website_url}}\"\n title: Fill_Out_Contact_Form\n navigation_goal: >-\n Find the contact form. Fill out the contact us form and submit it. Your\n goal is complete when the page says your message has been sent. In the\n case you can't find a contact us form, terminate.\n\n\n Fill out required fields as best you can using the following\n information:\n\n {{name}}\n\n {{email}}\n\n {{additional_information}}\n error_code_mapping: null\n max_retries: 0\n max_steps_per_run: null\n complete_on_download: false\n download_suffix: null\n parameter_keys: []\n totp_identifier: null\n totp_verification_url: null\n complete_criterion: \"\"\n terminate_criterion: \"\"\n include_action_history_in_verification: false\n - label: Extract_Email\n continue_on_failure: false\n block_type: extraction\n url: \"\"\n title: Extract_Email\n data_extraction_goal: \"Extract a company email if available \"\n data_schema: null\n max_retries: 0\n max_steps_per_run: null\n parameter_keys: []\n'\n"
},
{
"sdk": "python",
- "code": "\nfrom skyvern import Skyvern\n\n# Create a workflow in JSON format\nworkflow_definition = {\n \"title\": \"Contact Forms Workflow\",\n \"description\": \"Fill the contact form on the website\",\n \"proxy_location\": \"RESIDENTIAL\",\n \"webhook_callback_url\": \"https://example.com/webhook\",\n \"totp_verification_url\": \"https://example.com/totp\",\n \"totp_identifier\": \"4155555555\",\n \"model\": {\"name\": \"gpt-4.1\"},\n \"workflow_definition\": {\n \"parameters\": [\n {\n \"key\": \"website_url\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"name\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"additional_information\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": \"Message: I'd love to learn more about your...\nPhone: 123-456-7890\nInquiry type: sales\nOptional Subject: Hello from [Company Here]\",\n },\n {\n \"key\": \"email\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n ],\n \"blocks\": [\n {\n \"label\": \"Fill_Out_Contact_Form\",\n \"continue_on_failure\": True,\n \"block_type\": \"navigation\",\n \"url\": \"{{website_url}}\",\n \"title\": \"Fill_Out_Contact_Form\",\n \"engine\": \"skyvern-1.0\",\n \"navigation_goal\": \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}\",\n \"error_code_mapping\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"complete_on_download\": False,\n \"download_suffix\": None,\n \"parameter_keys\": [],\n \"totp_identifier\": None,\n \"totp_verification_url\": None,\n \"complete_criterion\": \"\",\n \"terminate_criterion\": \"\",\n \"include_action_history_in_verification\": False,\n },\n {\n \"label\": \"Extract_Email\",\n \"continue_on_failure\": False,\n \"block_type\": \"extraction\",\n \"url\": \"\",\n \"title\": \"Extract_Email\",\n \"data_extraction_goal\": \"Extract a company email if available \",\n \"data_schema\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"parameter_keys\": [],\n },\n ],\n },\n}\nskyvern = Skyvern(api_key=\"YOUR_API_KEY\")\nworkflow = await skyvern.create_workflow(json_definition=workflow_definition)\nprint(workflow)\n"
+ "code": "\nfrom skyvern import Skyvern\n\n# Create a workflow in JSON format\nworkflow_definition = {\n \"title\": \"Contact Forms Workflow\",\n \"description\": \"Fill the contact form on the website\",\n \"proxy_location\": \"RESIDENTIAL\",\n \"webhook_callback_url\": \"https://example.com/webhook\",\n \"totp_verification_url\": \"https://example.com/totp\",\n \"totp_identifier\": \"4155555555\",\n \"model\": {\"name\": \"gpt-4.1\"},\n \"workflow_definition\": {\n \"parameters\": [\n {\n \"key\": \"website_url\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"name\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"additional_information\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": \"Message: I'd love to learn more about your...\nPhone: 123-456-7890\nInquiry type: sales\nOptional Subject: Hello from [Company Here]\",\n },\n {\n \"key\": \"email\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n ],\n \"blocks\": [\n {\n \"label\": \"Fill_Out_Contact_Form\",\n \"continue_on_failure\": True,\n \"block_type\": \"navigation\",\n \"url\": \"{{website_url}}\",\n \"title\": \"Fill_Out_Contact_Form\",\n \"navigation_goal\": \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}\",\n \"error_code_mapping\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"complete_on_download\": False,\n \"download_suffix\": None,\n \"parameter_keys\": [],\n \"totp_identifier\": None,\n \"totp_verification_url\": None,\n \"complete_criterion\": \"\",\n \"terminate_criterion\": \"\",\n \"include_action_history_in_verification\": False,\n },\n {\n \"label\": \"Extract_Email\",\n \"continue_on_failure\": False,\n \"block_type\": \"extraction\",\n \"url\": \"\",\n \"title\": \"Extract_Email\",\n \"data_extraction_goal\": \"Extract a company email if available \",\n \"data_schema\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"parameter_keys\": [],\n },\n ],\n },\n}\nskyvern = Skyvern(api_key=\"YOUR_API_KEY\")\nworkflow = await skyvern.create_workflow(json_definition=workflow_definition)\nprint(workflow)\n"
},
{
"sdk": "typescript",
- "code": "import { SkyvernClient } from \"@skyvern/client\";\n\nconst skyvern = new SkyvernClient({ apiKey: \"YOUR_API_KEY\" });\n\n// Create a workflow in JSON format\nconst workflowDefinition = {\n title: \"Contact Forms Workflow\",\n description: \"Fill the contact form on the website\",\n proxy_location: \"RESIDENTIAL\",\n webhook_callback_url: \"https://example.com/webhook\",\n totp_verification_url: \"https://example.com/totp\",\n totp_identifier: \"4155555555\",\n model: { name: \"gpt-4.1\" },\n workflow_definition: {\n parameters: [\n {\n key: \"website_url\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"name\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"additional_information\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: \"Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]\"\n },\n {\n key: \"email\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n }\n ],\n blocks: [\n {\n label: \"Fill_Out_Contact_Form\",\n continue_on_failure: true,\n block_type: \"navigation\",\n url: \"{{website_url}}\",\n title: \"Fill_Out_Contact_Form\",\n engine: \"skyvern-1.0\",\n navigation_goal: \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}\",\n error_code_mapping: null,\n max_retries: 0,\n max_steps_per_run: null,\n complete_on_download: false,\n download_suffix: null,\n parameter_keys: [],\n totp_identifier: null,\n totp_verification_url: null,\n complete_criterion: \"\",\n terminate_criterion: \"\",\n include_action_history_in_verification: false\n },\n {\n label: \"Extract_Email\",\n continue_on_failure: false,\n block_type: \"extraction\",\n url: \"\",\n title: \"Extract_Email\",\n data_extraction_goal: \"Extract a company email if available \",\n data_schema: null,\n max_retries: 0,\n max_steps_per_run: null,\n parameter_keys: [],\n }\n ]\n }\n};\n\nconst workflow = await skyvern.createWorkflow({\n json_definition: workflowDefinition\n});\nconsole.log(workflow);\n"
+ "code": "import { SkyvernClient } from \"@skyvern/client\";\n\nconst skyvern = new SkyvernClient({ apiKey: \"YOUR_API_KEY\" });\n\n// Create a workflow in JSON format\nconst workflowDefinition = {\n title: \"Contact Forms Workflow\",\n description: \"Fill the contact form on the website\",\n proxy_location: \"RESIDENTIAL\",\n webhook_callback_url: \"https://example.com/webhook\",\n totp_verification_url: \"https://example.com/totp\",\n totp_identifier: \"4155555555\",\n model: { name: \"gpt-4.1\" },\n workflow_definition: {\n parameters: [\n {\n key: \"website_url\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"name\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"additional_information\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: \"Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]\"\n },\n {\n key: \"email\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n }\n ],\n blocks: [\n {\n label: \"Fill_Out_Contact_Form\",\n continue_on_failure: true,\n block_type: \"navigation\",\n url: \"{{website_url}}\",\n title: \"Fill_Out_Contact_Form\",\n navigation_goal: \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}\",\n error_code_mapping: null,\n max_retries: 0,\n max_steps_per_run: null,\n complete_on_download: false,\n download_suffix: null,\n parameter_keys: [],\n totp_identifier: null,\n totp_verification_url: null,\n complete_criterion: \"\",\n terminate_criterion: \"\",\n include_action_history_in_verification: false\n },\n {\n label: \"Extract_Email\",\n continue_on_failure: false,\n block_type: \"extraction\",\n url: \"\",\n title: \"Extract_Email\",\n data_extraction_goal: \"Extract a company email if available \",\n data_schema: null,\n max_retries: 0,\n max_steps_per_run: null,\n parameter_keys: [],\n }\n ]\n }\n};\n\nconst workflow = await skyvern.createWorkflow({\n json_definition: workflowDefinition\n});\nconsole.log(workflow);\n"
}
]
}
@@ -900,15 +900,15 @@
"code-samples": [
{
"sdk": "curl",
- "code": "curl -X POST https://api.skyvern.com/v1/workflows/wpid_123 --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: text/plain' --data-raw 'title: Contact Forms\ndescription: Fill the contact form on the website\nproxy_location: RESIDENTIAL\nwebhook_callback_url: https://example.com/webhook\ntotp_verification_url: https://example.com/totp\npersist_browser_session: false\nmodel:\n name: gpt-4.1\nworkflow_definition:\n parameters:\n - key: website_url\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: name\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: additional_information\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: |-\n Message: I'd love to learn more about your...\n Phone: 123-456-7890\n Inquiry type: sales\n Optional Subject: Hello from [Company Here]\n - key: email\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n blocks:\n - label: Fill_Out_Contact_Form\n continue_on_failure: true\n block_type: navigation\n url: \"{{website_url}}\"\n title: Fill_Out_Contact_Form\n engine: skyvern-1.0\n navigation_goal: >-\n Find the contact form. Fill out the contact us form and submit it. Your\n goal is complete when the page says your message has been sent. In the\n case you can't find a contact us form, terminate.\n\n\n Fill out required fields as best you can using the following\n information:\n\n {{name}}\n\n {{email}}\n\n {{additional_information}}\n error_code_mapping: null\n max_retries: 0\n max_steps_per_run: null\n complete_on_download: false\n download_suffix: null\n parameter_keys: []\n totp_identifier: null\n totp_verification_url: null\n complete_criterion: \"\"\n terminate_criterion: \"\"\n include_action_history_in_verification: false\n - label: Extract_Email\n continue_on_failure: false\n block_type: extraction\n url: \"\"\n title: Extract_Email\n data_extraction_goal: \"Extract a company email if available \"\n data_schema: null\n max_retries: 0\n max_steps_per_run: null\n parameter_keys: []\n'\n"
+ "code": "curl -X POST https://api.skyvern.com/v1/workflows/wpid_123 --header 'x-api-key: {{x-api-key}}' --header 'Content-Type: text/plain' --data-raw 'title: Contact Forms\ndescription: Fill the contact form on the website\nproxy_location: RESIDENTIAL\nwebhook_callback_url: https://example.com/webhook\ntotp_verification_url: https://example.com/totp\npersist_browser_session: false\nmodel:\n name: gpt-4.1\nworkflow_definition:\n parameters:\n - key: website_url\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: name\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n - key: additional_information\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: |-\n Message: I'd love to learn more about your...\n Phone: 123-456-7890\n Inquiry type: sales\n Optional Subject: Hello from [Company Here]\n - key: email\n description: null\n parameter_type: workflow\n workflow_parameter_type: string\n default_value: null\n blocks:\n - label: Fill_Out_Contact_Form\n continue_on_failure: true\n block_type: navigation\n url: \"{{website_url}}\"\n title: Fill_Out_Contact_Form\n navigation_goal: >-\n Find the contact form. Fill out the contact us form and submit it. Your\n goal is complete when the page says your message has been sent. In the\n case you can't find a contact us form, terminate.\n\n\n Fill out required fields as best you can using the following\n information:\n\n {{name}}\n\n {{email}}\n\n {{additional_information}}\n error_code_mapping: null\n max_retries: 0\n max_steps_per_run: null\n complete_on_download: false\n download_suffix: null\n parameter_keys: []\n totp_identifier: null\n totp_verification_url: null\n complete_criterion: \"\"\n terminate_criterion: \"\"\n include_action_history_in_verification: false\n - label: Extract_Email\n continue_on_failure: false\n block_type: extraction\n url: \"\"\n title: Extract_Email\n data_extraction_goal: \"Extract a company email if available \"\n data_schema: null\n max_retries: 0\n max_steps_per_run: null\n parameter_keys: []\n'\n"
},
{
"sdk": "python",
- "code": "\nfrom skyvern import Skyvern\n\nupdated_workflow_definition = {\n \"title\": \"Updated Contact Forms Workflow\",\n \"description\": \"Fill the contact form on the website\",\n \"proxy_location\": \"RESIDENTIAL\",\n \"webhook_callback_url\": \"https://example.com/webhook\",\n \"totp_verification_url\": \"https://example.com/totp\",\n \"totp_identifier\": \"4155555555\",\n \"model\": {\"name\": \"gpt-4.1\"},\n \"workflow_definition\": {\n \"parameters\": [\n {\n \"key\": \"website_url\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"name\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"additional_information\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": \"Message: I'd love to learn more about your...\nPhone: 123-456-7890\nInquiry type: sales\nOptional Subject: Hello from [Company Here]\",\n },\n {\n \"key\": \"email\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n ],\n \"blocks\": [\n {\n \"label\": \"Fill_Out_Contact_Form\",\n \"continue_on_failure\": True,\n \"block_type\": \"navigation\",\n \"url\": \"{{website_url}}\",\n \"title\": \"Fill_Out_Contact_Form\",\n \"engine\": \"skyvern-1.0\",\n \"navigation_goal\": \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}\",\n \"error_code_mapping\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"complete_on_download\": False,\n \"download_suffix\": None,\n \"parameter_keys\": [],\n \"totp_identifier\": None,\n \"totp_verification_url\": None,\n \"complete_criterion\": \"\",\n \"terminate_criterion\": \"\",\n \"include_action_history_in_verification\": False,\n },\n {\n \"label\": \"Extract_Email\",\n \"continue_on_failure\": False,\n \"block_type\": \"extraction\",\n \"url\": \"\",\n \"title\": \"Extract_Email\",\n \"data_extraction_goal\": \"Extract a company email if available \",\n \"data_schema\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"parameter_keys\": [],\n },\n ],\n },\n}\nskyvern = Skyvern(api_key=\"YOUR_API_KEY\")\nworkflow = await skyvern.update_workflow(workflow_id=\"wpid_123\", json_definition=updated_workflow_definition)\nprint(workflow)\n"
+ "code": "\nfrom skyvern import Skyvern\n\nupdated_workflow_definition = {\n \"title\": \"Updated Contact Forms Workflow\",\n \"description\": \"Fill the contact form on the website\",\n \"proxy_location\": \"RESIDENTIAL\",\n \"webhook_callback_url\": \"https://example.com/webhook\",\n \"totp_verification_url\": \"https://example.com/totp\",\n \"totp_identifier\": \"4155555555\",\n \"model\": {\"name\": \"gpt-4.1\"},\n \"workflow_definition\": {\n \"parameters\": [\n {\n \"key\": \"website_url\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"name\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n {\n \"key\": \"additional_information\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": \"Message: I'd love to learn more about your...\nPhone: 123-456-7890\nInquiry type: sales\nOptional Subject: Hello from [Company Here]\",\n },\n {\n \"key\": \"email\",\n \"description\": None,\n \"parameter_type\": \"workflow\",\n \"workflow_parameter_type\": \"string\",\n \"default_value\": None,\n },\n ],\n \"blocks\": [\n {\n \"label\": \"Fill_Out_Contact_Form\",\n \"continue_on_failure\": True,\n \"block_type\": \"navigation\",\n \"url\": \"{{website_url}}\",\n \"title\": \"Fill_Out_Contact_Form\",\n \"navigation_goal\": \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}\",\n \"error_code_mapping\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"complete_on_download\": False,\n \"download_suffix\": None,\n \"parameter_keys\": [],\n \"totp_identifier\": None,\n \"totp_verification_url\": None,\n \"complete_criterion\": \"\",\n \"terminate_criterion\": \"\",\n \"include_action_history_in_verification\": False,\n },\n {\n \"label\": \"Extract_Email\",\n \"continue_on_failure\": False,\n \"block_type\": \"extraction\",\n \"url\": \"\",\n \"title\": \"Extract_Email\",\n \"data_extraction_goal\": \"Extract a company email if available \",\n \"data_schema\": None,\n \"max_retries\": 0,\n \"max_steps_per_run\": None,\n \"parameter_keys\": [],\n },\n ],\n },\n}\nskyvern = Skyvern(api_key=\"YOUR_API_KEY\")\nworkflow = await skyvern.update_workflow(workflow_id=\"wpid_123\", json_definition=updated_workflow_definition)\nprint(workflow)\n"
},
{
"sdk": "typescript",
- "code": "import { SkyvernClient } from \"@skyvern/client\";\n\nconst skyvern = new SkyvernClient({ apiKey: \"YOUR_API_KEY\" });\n\nconst updatedWorkflowDefinition = {\n title: \"Updated Contact Forms Workflow\",\n description: \"Fill the contact form on the website\",\n proxy_location: \"RESIDENTIAL\",\n webhook_callback_url: \"https://example.com/webhook\",\n totp_verification_url: \"https://example.com/totp\",\n totp_identifier: \"4155555555\",\n model: { name: \"gpt-4.1\" },\n workflow_definition: {\n parameters: [\n {\n key: \"website_url\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"name\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"additional_information\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: \"Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]\"\n },\n {\n key: \"email\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n }\n ],\n blocks: [\n {\n label: \"Fill_Out_Contact_Form\",\n continue_on_failure: true,\n block_type: \"navigation\",\n url: \"{{website_url}}\",\n title: \"Fill_Out_Contact_Form\",\n engine: \"skyvern-1.0\",\n navigation_goal: \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}\",\n error_code_mapping: null,\n max_retries: 0,\n max_steps_per_run: null,\n complete_on_download: false,\n download_suffix: null,\n parameter_keys: [],\n totp_identifier: null,\n totp_verification_url: null,\n complete_criterion: \"\",\n terminate_criterion: \"\",\n include_action_history_in_verification: false\n },\n {\n label: \"Extract_Email\",\n continue_on_failure: false,\n block_type: \"extraction\",\n url: \"\",\n title: \"Extract_Email\",\n data_extraction_goal: \"Extract a company email if available \",\n data_schema: null,\n max_retries: 0,\n max_steps_per_run: null,\n parameter_keys: []\n }\n ]\n }\n};\n\nconst workflow = await skyvern.updateWorkflow(\"wpid_123\", {\n json_definition: updatedWorkflowDefinition\n});\nconsole.log(workflow);\n"
+ "code": "import { SkyvernClient } from \"@skyvern/client\";\n\nconst skyvern = new SkyvernClient({ apiKey: \"YOUR_API_KEY\" });\n\nconst updatedWorkflowDefinition = {\n title: \"Updated Contact Forms Workflow\",\n description: \"Fill the contact form on the website\",\n proxy_location: \"RESIDENTIAL\",\n webhook_callback_url: \"https://example.com/webhook\",\n totp_verification_url: \"https://example.com/totp\",\n totp_identifier: \"4155555555\",\n model: { name: \"gpt-4.1\" },\n workflow_definition: {\n parameters: [\n {\n key: \"website_url\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"name\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n },\n {\n key: \"additional_information\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: \"Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]\"\n },\n {\n key: \"email\",\n description: null,\n parameter_type: \"workflow\",\n workflow_parameter_type: \"string\",\n default_value: null\n }\n ],\n blocks: [\n {\n label: \"Fill_Out_Contact_Form\",\n continue_on_failure: true,\n block_type: \"navigation\",\n url: \"{{website_url}}\",\n title: \"Fill_Out_Contact_Form\",\n navigation_goal: \"Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}\",\n error_code_mapping: null,\n max_retries: 0,\n max_steps_per_run: null,\n complete_on_download: false,\n download_suffix: null,\n parameter_keys: [],\n totp_identifier: null,\n totp_verification_url: null,\n complete_criterion: \"\",\n terminate_criterion: \"\",\n include_action_history_in_verification: false\n },\n {\n label: \"Extract_Email\",\n continue_on_failure: false,\n block_type: \"extraction\",\n url: \"\",\n title: \"Extract_Email\",\n data_extraction_goal: \"Extract a company email if available \",\n data_schema: null,\n max_retries: 0,\n max_steps_per_run: null,\n parameter_keys: []\n }\n ]\n }\n};\n\nconst workflow = await skyvern.updateWorkflow(\"wpid_123\", {\n json_definition: updatedWorkflowDefinition\n});\nconsole.log(workflow);\n"
}
]
}
diff --git a/skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx b/skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx
index 5faf35944..4875c63fc 100644
--- a/skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx
+++ b/skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx
@@ -16,6 +16,7 @@ import {
ArchiveEntry,
expandFileToWorkflowYamls,
extractTitleFromYaml,
+ stripLegacyEngineFromYaml,
unzipArchive,
} from "./importWorkflowYaml";
import { WorkflowApiResponse } from "./types/workflowTypes";
@@ -85,7 +86,7 @@ function ImportWorkflowButton({
}
await client.post<string, { data: WorkflowApiResponse }>(
"/workflows",
- yaml,
+ stripLegacyEngineFromYaml(yaml),
{
headers: {
"Content-Type": "text/plain",
diff --git a/skyvern-frontend/src/routes/workflows/importWorkflowYaml.test.ts b/skyvern-frontend/src/routes/workflows/importWorkflowYaml.test.ts
index cbbf100d0..7d0875cce 100644
--- a/skyvern-frontend/src/routes/workflows/importWorkflowYaml.test.ts
+++ b/skyvern-frontend/src/routes/workflows/importWorkflowYaml.test.ts
@@ -5,6 +5,7 @@ import { parse as parseYAML, stringify as convertToYAML } from "yaml";
import {
expandFileToWorkflowYamls,
extractTitleFromYaml,
+ stripLegacyEngineFromYaml,
unzipArchive,
} from "./importWorkflowYaml";
@@ -74,6 +75,24 @@ describe("expandFileToWorkflowYamls", () => {
expect(() => expandFileToWorkflowYamls(bundle)).toThrow();
});
+ it("converts JSON strings so the backend's YAML 1.1 parser keeps them strings", () => {
+ const [yaml] = expandFileToWorkflowYamls(
+ JSON.stringify({ title: "on", goal: "1_000" }),
+ );
+ expect(parseYAML(yaml!, { version: "1.1" })).toEqual({
+ title: "on",
+ goal: "1_000",
+ });
+ });
+
+ it("splits a bundle into each document's own text, so every value reaches the backend as written", () => {
+ const first =
+ "# first\ntitle: A\nflag: Y\nn: n\ncount: 1e3\nwhen: 2024-01-01 10:00:00-05:00\n";
+ const second = "---\ntitle: B # kept\nflag: 'on'\n";
+ const expanded = expandFileToWorkflowYamls(first + second);
+ expect(expanded).toEqual([first, second]);
+ });
+
it("returns a single JSON array element as one workflow", () => {
const bundle = JSON.stringify([workflowA]);
@@ -166,3 +185,103 @@ describe("extractTitleFromYaml", () => {
expect(extractTitleFromYaml(": : invalid : :")).toBeNull();
});
});
+
+describe("stripLegacyEngineFromYaml", () => {
+ const workflow = {
+ title: "W",
+ workflow_definition: {
+ blocks: [
+ { block_type: "navigation", label: "a", engine: "skyvern-1.0" },
+ { block_type: "navigation", label: "b", engine: "skyvern-2.0" },
+ { block_type: "navigation", label: "c", engine: "skyvern-3.0" },
+ { block_type: "navigation", label: "d" },
+ {
+ block_type: "for_loop",
+ label: "e",
+ loop_blocks: [
+ { block_type: "navigation", label: "f", engine: "skyvern-1.0" },
+ { block_type: "navigation", label: "g", engine: "skyvern-3.0" },
+ ],
+ },
+ ],
+ },
+ };
+
+ it("unsets skyvern-1.0 at any depth and keeps every other engine", () => {
+ const out = parseYAML(stripLegacyEngineFromYaml(convertToYAML(workflow)))
+ .workflow_definition.blocks;
+ expect(out[0]).not.toHaveProperty("engine");
+ expect(out[1].engine).toBe("skyvern-2.0");
+ expect(out[2].engine).toBe("skyvern-3.0");
+ expect(out[3]).not.toHaveProperty("engine");
+ expect(out[4].loop_blocks[0]).not.toHaveProperty("engine");
+ expect(out[4].loop_blocks[1].engine).toBe("skyvern-3.0");
+ });
+
+ it("returns a file with no legacy engine byte-for-byte", () => {
+ const clean =
+ "# kept\ntitle: t\nworkflow_definition:\n blocks:\n - block_type: navigation\n label: a\n engine: skyvern-3.0\n";
+ expect(stripLegacyEngineFromYaml(clean)).toBe(clean);
+ });
+
+ const lines = [
+ "# exported",
+ "title: t",
+ "workflow_definition:",
+ " parameters:",
+ " - key: flag",
+ " default_value: Y",
+ " - key: other",
+ " default_value: n",
+ " blocks:",
+ " - block_type: navigation",
+ " label: a",
+ " engine: skyvern-1.0 # legacy",
+ " navigation_goal: 1e3",
+ " complete_criterion: 2001-12-14 21:59:43.10 -05:00",
+ " - engine: skyvern-1.0",
+ " block_type: navigation",
+ " label: b",
+ " - block_type: for_loop",
+ " label: c",
+ " loop_blocks:",
+ " - block_type: navigation",
+ " label: d",
+ " engine: 'skyvern-1.0'",
+ " - block_type: navigation",
+ " label: e",
+ " engine: skyvern-3.0",
+ " - block_type: navigation",
+ " label: f",
+ " engine: null",
+ "",
+ ];
+
+ const withoutLegacy = [...lines];
+ withoutLegacy.splice(22, 1);
+ withoutLegacy.splice(14, 2, " - block_type: navigation");
+ withoutLegacy.splice(11, 1);
+
+ it("removes only the skyvern-1.0 lines, at any depth, and leaves every other byte", () => {
+ expect(stripLegacyEngineFromYaml(lines.join("\n"))).toBe(
+ withoutLegacy.join("\n"),
+ );
+ });
+
+ it("returns a file with no skyvern-1.0 byte-for-byte, values and comments included", () => {
+ const clean = withoutLegacy.join("\n");
+ expect(clean).toContain("engine: null");
+ expect(stripLegacyEngineFromYaml(clean)).toBe(clean);
+ });
+
+ it("leaves a flow-style block holding skyvern-1.0 unchanged rather than rewrite it", () => {
+ const flow =
+ "workflow_definition:\n blocks:\n - {label: a, engine: skyvern-1.0, goal: Y}\n";
+ expect(stripLegacyEngineFromYaml(flow)).toBe(flow);
+ });
+
+ it("returns unparseable text unchanged", () => {
+ const bad = "title: [unclosed\n engine: skyvern-1.0";
+ expect(stripLegacyEngineFromYaml(bad)).toBe(bad);
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/importWorkflowYaml.ts b/skyvern-frontend/src/routes/workflows/importWorkflowYaml.ts
index 7cd3a4a09..a61965fd8 100644
--- a/skyvern-frontend/src/routes/workflows/importWorkflowYaml.ts
+++ b/skyvern-frontend/src/routes/workflows/importWorkflowYaml.ts
@@ -1,10 +1,17 @@
import { strFromU8, unzipSync } from "fflate";
import {
+ isMap,
+ isScalar,
+ isSeq,
parse as parseYAML,
parseAllDocuments,
+ parseDocument,
stringify as convertToYAML,
} from "yaml";
+import type { RunEngine } from "@/api/types";
+import { blockEngineForWorkflow } from "./editor/workflowEditorUtils";
+
function isJsonString(str: string): boolean {
try {
JSON.parse(str);
@@ -14,6 +21,12 @@ function isJsonString(str: string): boolean {
return true;
}
+// The backend parses with PyYAML (YAML 1.1), which reads plain `yes`, `on`, `1:30` or `1_000` as a bool or an
+// int; a 1.1 dump quotes those strings.
+function toBackendYaml(value: unknown): string {
+ return convertToYAML(value, { version: "1.1" });
+}
+
// Bulk export bundles N workflows into one file: multi-document YAML (docs
// joined by `---`) or a top-level JSON array. Split it back into one YAML
// string per workflow so each can be POSTed as its own workflow. A file that
@@ -22,9 +35,9 @@ export function expandFileToWorkflowYamls(text: string): string[] {
if (isJsonString(text)) {
const parsed = JSON.parse(text);
if (Array.isArray(parsed)) {
- return parsed.map((workflow) => convertToYAML(workflow));
+ return parsed.map((workflow) => toBackendYaml(workflow));
}
- return [convertToYAML(parsed)];
+ return [toBackendYaml(parsed)];
}
const documents = parseAllDocuments(text);
for (const document of documents) {
@@ -38,13 +51,21 @@ export function expandFileToWorkflowYamls(text: string): string[] {
throw new Error(error.message);
}
}
- const workflows = documents
- .map((document) => document.toJS())
- .filter((value) => value !== null && typeof value === "object");
+ // Each workflow is its document's own source text, never a re-dump, so every value reaches the backend as written.
+ const workflows: string[] = [];
+ let start = 0;
+ for (const document of documents) {
+ const end = document.range[2];
+ const value = document.toJS();
+ if (value !== null && typeof value === "object") {
+ workflows.push(text.slice(start, end));
+ }
+ start = end;
+ }
if (workflows.length <= 1) {
return [text];
}
- return workflows.map((workflow) => convertToYAML(workflow));
+ return workflows;
}
export type ArchiveEntry = { name: string; text: string };
@@ -100,3 +121,86 @@ export function extractTitleFromYaml(yaml: string): string | null {
}
return null;
}
+
+type Span = [number, number];
+
+// Returns the byte span of each `engine: skyvern-1.0` line, or null when one sits where it cannot be cut
+// without rewriting its neighbours (flow style, or sharing a line with other content).
+function legacyEngineSpans(text: string, blocks: unknown): Span[] | null {
+ if (!isSeq(blocks)) {
+ return [];
+ }
+ const spans: Span[] = [];
+ for (const block of blocks.items) {
+ if (!isMap(block)) {
+ continue;
+ }
+ for (const [index, pair] of block.items.entries()) {
+ const { key, value } = pair;
+ if (
+ !isScalar(key) ||
+ key.value !== "engine" ||
+ !isScalar(value) ||
+ typeof value.value !== "string" ||
+ blockEngineForWorkflow(value.value as RunEngine, null) !== null
+ ) {
+ continue;
+ }
+ if (blocks.flow || block.flow || !key.range || !value.range) {
+ return null;
+ }
+ const lineStart = text.lastIndexOf("\n", key.range[0] - 1) + 1;
+ const newline = text.indexOf("\n", value.range[1]);
+ const lineEnd = newline === -1 ? text.length : newline + 1;
+ if (
+ !/^[ \t\r]*(#[^\n]*)?\n?$/.test(text.slice(value.range[1], lineEnd))
+ ) {
+ return null;
+ }
+ const prefix = text.slice(lineStart, key.range[0]);
+ if (/^\s*$/.test(prefix)) {
+ spans.push([lineStart, lineEnd]);
+ continue;
+ }
+ // `- engine: skyvern-1.0` opens its block: cut up to the next key so it takes the `- `.
+ const next = block.items[index + 1]?.key;
+ if (
+ !/^\s*-\s+$/.test(prefix) ||
+ !isScalar(next) ||
+ !next.range ||
+ !/^\s*$/.test(text.slice(lineEnd, next.range[0]))
+ ) {
+ return null;
+ }
+ spans.push([key.range[0], next.range[0]]);
+ }
+ const nested = legacyEngineSpans(text, block.get("loop_blocks", true));
+ if (nested === null) {
+ return null;
+ }
+ spans.push(...nested);
+ }
+ return spans;
+}
+
+// Cuts only the legacy engine lines out of the original text, so every other byte reaches the backend as written.
+export function stripLegacyEngineFromYaml(yaml: string): string {
+ try {
+ const document = parseDocument(yaml);
+ if (document.errors.length > 0 || !isMap(document.contents)) {
+ return yaml;
+ }
+ const definition = document.contents.get("workflow_definition", true);
+ const spans = isMap(definition)
+ ? legacyEngineSpans(yaml, definition.get("blocks", true))
+ : null;
+ if (!spans) {
+ return yaml;
+ }
+ return spans
+ .sort((a, b) => b[0] - a[0])
+ .reduce((text, [from, to]) => text.slice(0, from) + text.slice(to), yaml);
+ } catch {
+ return yaml;
+ }
+}
diff --git a/skyvern-frontend/src/store/WorkflowHasChangesStore.recording.test.tsx b/skyvern-frontend/src/store/WorkflowHasChangesStore.recording.test.tsx
index 9c2ae1445..a0d80a4d5 100644
--- a/skyvern-frontend/src/store/WorkflowHasChangesStore.recording.test.tsx
+++ b/skyvern-frontend/src/store/WorkflowHasChangesStore.recording.test.tsx
@@ -716,63 +716,67 @@ describe("workflow recording attachment", () => {
},
);
- it("A46 keeps the cached effective_default_engine when a disposed-owner PUT hydrates the active editor", async () => {
- const owner = useWorkflowYamlEditorStore.getState().editorOwner!;
- const queryClient = new QueryClient({
- defaultOptions: { queries: { staleTime: 5 * 60 * 1000, retry: false } },
- });
- const queryKey = ["workflow", "wpid-1"];
- queryClient.setQueryData(queryKey, {
- ...saveData.workflow,
- effective_default_engine: "skyvern-3.0",
- });
- function cacheWrapper({ children }: { children: ReactNode }) {
- return (
- <QueryClientProvider client={queryClient}>
- {children}
- </QueryClientProvider>
+ it.each(["skyvern-3.0", null])(
+ "A46 keeps the cached effective_default_engine %s when a disposed-owner PUT without it hydrates the active editor",
+ async (cachedEngine) => {
+ const owner = useWorkflowYamlEditorStore.getState().editorOwner!;
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { staleTime: 5 * 60 * 1000, retry: false } },
+ });
+ const queryKey = ["workflow", "wpid-1"];
+ queryClient.setQueryData(queryKey, {
+ ...saveData.workflow,
+ effective_default_engine: cachedEngine,
+ });
+ function cacheWrapper({ children }: { children: ReactNode }) {
+ return (
+ <QueryClientProvider client={queryClient}>
+ {children}
+ </QueryClientProvider>
+ );
+ }
+ let resolvePut!: (value: unknown) => void;
+ mocks.put.mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ resolvePut = resolve;
+ }),
);
- }
- let resolvePut!: (value: unknown) => void;
- mocks.put.mockImplementationOnce(
- () =>
- new Promise((resolve) => {
- resolvePut = resolve;
- }),
- );
- const hook = renderHook(() => useWorkflowSave(), { wrapper: cacheWrapper });
- beginYamlCommit(owner);
- let saving!: Promise<unknown>;
- act(() => {
- saving = hook.result.current.mutateAsync({
- yamlCommit: {
- owner,
- revision: useWorkflowYamlEditorStore.getState().revision,
- },
+ const hook = renderHook(() => useWorkflowSave(), {
+ wrapper: cacheWrapper,
});
- });
- await waitFor(() => expect(mocks.put).toHaveBeenCalledOnce());
- hook.unmount();
- unregisterEditorOwner(owner);
- registerEditorOwner(createYamlCommitOwner("wpid-1"));
- const hydrate = vi.fn();
- useWorkflowHasChangesStore.setState({ hydrateSavedSettings: hydrate });
- await act(async () => {
- resolvePut({
- data: {
- ...saveData.workflow,
- title: "Original saved",
- effective_default_engine: null,
- },
+ beginYamlCommit(owner);
+ let saving!: Promise<unknown>;
+ act(() => {
+ saving = hook.result.current.mutateAsync({
+ yamlCommit: {
+ owner,
+ revision: useWorkflowYamlEditorStore.getState().revision,
+ },
+ });
});
- await saving;
- });
- expect(hydrate).toHaveBeenCalledOnce();
- expect(queryClient.getQueryData(queryKey)).toMatchObject({
- title: "Original saved",
- effective_default_engine: "skyvern-3.0",
- });
- });
+ await waitFor(() => expect(mocks.put).toHaveBeenCalledOnce());
+ hook.unmount();
+ unregisterEditorOwner(owner);
+ registerEditorOwner(createYamlCommitOwner("wpid-1"));
+ const hydrate = vi.fn();
+ useWorkflowHasChangesStore.setState({ hydrateSavedSettings: hydrate });
+ await act(async () => {
+ resolvePut({
+ data: {
+ ...saveData.workflow,
+ title: "Original saved",
+ },
+ });
+ await saving;
+ });
+ expect(hydrate).toHaveBeenCalledOnce();
+ expect(queryClient.getQueryData(queryKey)).toMatchObject({
+ title: "Original saved",
+ effective_default_engine: cachedEngine,
+ });
+ },
+ );
it("A46 clears an attached recording after disposed-owner success without deleting it", async () => {
const owner = useWorkflowYamlEditorStore.getState().editorOwner!;
diff --git a/skyvern-frontend/src/store/WorkflowHasChangesStore.ts b/skyvern-frontend/src/store/WorkflowHasChangesStore.ts
index a77637d93..518790a38 100644
--- a/skyvern-frontend/src/store/WorkflowHasChangesStore.ts
+++ b/skyvern-frontend/src/store/WorkflowHasChangesStore.ts
@@ -495,14 +495,15 @@ const useWorkflowSave = (opts?: WorkflowSaveOpts) => {
useWorkflowHasChangesStore
.getState()
.clearPendingRecording(recordingId);
- // Only the detail GET computes effective_default_engine; the PUT returns null for it.
+ // Only the detail GET computes effective_default_engine; the PUT omits it.
queryClient.setQueryData(
["workflow", saveData.workflow.workflow_permanent_id],
(prev?: WorkflowApiResponse) => ({
...response.data,
effective_default_engine:
- prev?.effective_default_engine ??
- response.data.effective_default_engine,
+ "effective_default_engine" in response.data
+ ? response.data.effective_default_engine
+ : prev?.effective_default_engine,
}),
);
setHasChanges(false, { fromYamlCommit: true });
diff --git a/skyvern/cli/mcp_tools/instructions.py b/skyvern/cli/mcp_tools/instructions.py
index e7c2050b4..19594c8e6 100644
--- a/skyvern/cli/mcp_tools/instructions.py
+++ b/skyvern/cli/mcp_tools/instructions.py
@@ -135,10 +135,11 @@ GOOD (4 blocks, clear single responsibility):
BAD: One giant block trying to do everything at once.
### Engine Selection
-- Known path (all fields/actions specified in prompt) -> skyvern-1.0 (default, omit engine field)
+- Known path (all fields/actions specified in prompt) -> omit the engine field (the default engine)
- Dynamic planning (discover what to do at runtime) -> skyvern-2.0
+- User asks for 1.0 (or 2.0) -> set `engine: skyvern-1.0` (or `engine: skyvern-2.0`) explicitly
- skyvern_run_task always uses 2.0 (cannot change)
-- When in doubt, split into multiple 1.0 blocks (cheaper, more observable)
+- When in doubt, split into multiple default-engine blocks (cheaper, more observable)
### Caching
When omitted, MCP-created workflows default to run_with="agent" and code_version=2 for both JSON \
diff --git a/skyvern/cli/mcp_tools/prompts.py b/skyvern/cli/mcp_tools/prompts.py
index 386abee53..62f3acf5f 100644
--- a/skyvern/cli/mcp_tools/prompts.py
+++ b/skyvern/cli/mcp_tools/prompts.py
@@ -75,9 +75,11 @@ Use skyvern_block_schema() to see full schemas and examples for any block type.
### Engine selection for workflow blocks
-Task-based blocks (navigation, extraction, action, login, file_download) default to engine 1.0 (`skyvern-1.0`).
-Omit the `engine` field unless you need 2.0. Non-task blocks (for_loop, conditional, code, wait, etc.)
-do not have an engine field — do not set one.
+Task-based blocks (navigation, extraction, action, login, file_download) run on the default engine
+when `engine` is omitted; which engine that is depends on when the workflow was created.
+Omit the `engine` field unless you need 2.0 or the user asks for a specific engine.
+If the user asks for 1.0, set `engine: skyvern-1.0` explicitly (likewise `engine: skyvern-2.0` for 2.0).
+Non-task blocks (for_loop, conditional, code, wait, etc.) do not have an engine field — do not set one.
Use engine 2.0 (`"engine": "skyvern-2.0"`) on a **navigation** block when:
- The block's goal requires dynamic planning — discovering what to do at runtime, conditional
@@ -85,12 +87,12 @@ Use engine 2.0 (`"engine": "skyvern-2.0"`) on a **navigation** block when:
- Example: "Navigate through a multi-step insurance quote wizard, handling dynamic questions
based on previous answers, then extract the final quote."
-Keep engine 1.0 (default, omit field) when:
+Keep the default engine (omit the field) when:
- The path is known upfront — all fields, values, and actions are specified in the prompt.
-- A long prompt with many form fields is still 1.0. Complexity means dynamic planning, not field count.
+- A long prompt with many form fields still omits it. Complexity means dynamic planning, not field count.
- Example: "Fill in SSN, first name, last name, select 'Sole Proprietor', click Continue."
-When in doubt, split into multiple 1.0 blocks rather than using one 2.0 block — it's cheaper and
+When in doubt, split into multiple default-engine blocks rather than using one 2.0 block — it's cheaper and
gives you per-block observability. Only navigation blocks support engine 2.0.
### Model selection for text_prompt blocks
diff --git a/skyvern/cli/skills/skyvern/SKILL.md b/skyvern/cli/skills/skyvern/SKILL.md
index da5bbc2eb..3197547bb 100644
--- a/skyvern/cli/skills/skyvern/SKILL.md
+++ b/skyvern/cli/skills/skyvern/SKILL.md
@@ -178,7 +178,8 @@ skyvern block schema --type navigation # discover block types
skyvern block validate --block-json @block.json # validate before creating
```
-Engine: known path = 1.0 (default). Dynamic planning = 2.0. Split into multiple 1.0 blocks when in doubt.
+Engine: known path = omit `engine` (the default engine). Dynamic planning = 2.0. Split into multiple default-engine blocks when in doubt.
+User asks for 1.0 (or 2.0) -> set `engine: skyvern-1.0` (or `engine: skyvern-2.0`) explicitly.
Status lifecycle: `created -> queued -> running -> completed | failed | canceled | terminated | timed_out`
## Common Patterns
diff --git a/skyvern/forge/log_redaction.py b/skyvern/forge/log_redaction.py
index 21843336d..d441e2aac 100644
--- a/skyvern/forge/log_redaction.py
+++ b/skyvern/forge/log_redaction.py
@@ -76,6 +76,9 @@ SENSITIVE_FIELDS: set[str] = {
"totp_identifier",
"totp_url",
"totp_secret",
+ "client_secret",
+ "access_token",
+ "refresh_token",
} | SENSITIVE_HEADERS
_PROXY_OBSERVABILITY_FIELDS = {field.value: field for field in ProxyObservabilityField}
diff --git a/skyvern/forge/prompts/skyvern/build-workflow-from-pdf.j2 b/skyvern/forge/prompts/skyvern/build-workflow-from-pdf.j2
index 4c2e17d2b..9ae76eb77 100644
--- a/skyvern/forge/prompts/skyvern/build-workflow-from-pdf.j2
+++ b/skyvern/forge/prompts/skyvern/build-workflow-from-pdf.j2
@@ -65,13 +65,13 @@ AVAILABLE BLOCK TYPES (use these exact names):
BLOCK STRUCTURE REQUIREMENTS:
1. Each block MUST have: label, block_type, continue_on_failure
-2. Navigation blocks need: url (can be empty string ""), navigation_goal, engine (set to "skyvern-1.0")
-3. Login blocks need: url, navigation_goal, parameter_keys (empty array if no credentials), engine (set to "skyvern-1.0")
-4. Extraction blocks need: url (can be empty string ""), data_extraction_goal, data_schema (use snake_case for all field names, e.g., product_name, order_date), engine (set to "skyvern-1.0")
-5. Action blocks need: url (can be empty string ""), navigation_goal, engine (set to "skyvern-1.0")
+2. Navigation blocks need: url (can be empty string ""), navigation_goal
+3. Login blocks need: url, navigation_goal, parameter_keys (empty array if no credentials)
+4. Extraction blocks need: url (can be empty string ""), data_extraction_goal, data_schema (use snake_case for all field names, e.g., product_name, order_date)
+5. Action blocks need: url (can be empty string ""), navigation_goal
6. Validation blocks need: complete_criterion OR terminate_criterion (at least one must be set), parameter_keys (empty array if none)
7. For_loop blocks need: loop_blocks, loop_variable_reference
-8. File_download blocks need: url (can be empty string ""), navigation_goal, engine (set to "skyvern-1.0")
+8. File_download blocks need: url (can be empty string ""), navigation_goal
CRITICAL INSTRUCTIONS - READ CAREFULLY:
1. **BE THOROUGH**: Convert EVERY automatable step from the SOP into a block. Do not skip or combine steps.
@@ -84,8 +84,7 @@ CRITICAL INSTRUCTIONS - READ CAREFULLY:
8. **URL FIELD**: Most blocks need a "url" field. Use empty string "" if no specific URL is needed (browser stays on current page).
9. **AVOID VALIDATION BLOCKS**: Use "extraction" blocks for data extraction. Only use "validation" if explicitly validating previous extracted data, and always include complete_criterion.
10. Set continue_on_failure to false for critical steps, true for optional ones
-11. Set engine to "skyvern-1.0" for all blocks that need it
-12. Use SHORT descriptive labels (1-5 words, snake_case): e.g., "login", "extract_date_data", "submit_google_login_form". Avoid long labels.
+11. Use SHORT descriptive labels (1-5 words, snake_case): e.g., "login", "extract_date_data", "submit_google_login_form". Avoid long labels.
EXAMPLES OF THOROUGHNESS:
- If SOP says "Navigate to page X, then click button Y, then fill form Z" → Create 3 separate blocks
diff --git a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
index afdf787a0..0d017a008 100644
--- a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
+++ b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
@@ -588,7 +588,6 @@ label: <unique_label>
navigation_goal: <download_instruction> # Required: How to trigger the download
url: <starting_url> # Optional: URL to navigate to first
title: str # Optional: Title for the block
-engine: skyvern-1.0 # Optional: Run engine
error_code_mapping: {} # Optional: Map errors to custom codes
max_retries: 0 # Optional: Number of retry attempts
max_steps_per_run: null # Optional: Limit steps per execution
diff --git a/skyvern/forge/request_logging.py b/skyvern/forge/request_logging.py
index b058aeb68..983a39754 100644
--- a/skyvern/forge/request_logging.py
+++ b/skyvern/forge/request_logging.py
@@ -61,6 +61,10 @@ _SENSITIVE_ENDPOINT_PATTERNS = (
re.compile(r"^(?:POST|PUT|PATCH|DELETE) /(?:api/)?v1/(?:integrations/twilio|sms)(?:/.*)?$"),
# MCP arguments and results can contain arbitrary secrets, including malformed JSON.
re.compile(r"^[^ ]+ /mcp(?:/.*)?$", re.DOTALL),
+ # OAuth grants carry form-encoded client secrets and codes, and their responses carry tokens.
+ re.compile(r"^POST /oauth/(?:token|consent|callback)$"),
+ # Marketplace service routes return freshly minted client secrets.
+ re.compile(r"^POST /(?:api/)?v1/marketplace(?:/.*)?$"),
)
_MAX_BODY_LENGTH = 1000
_READ_METHODS = frozenset({"GET", "HEAD", "OPTIONS"})
diff --git a/skyvern/forge/sdk/experimentation/workflow_block_engine.py b/skyvern/forge/sdk/experimentation/workflow_block_engine.py
index 572695789..11f227db0 100644
--- a/skyvern/forge/sdk/experimentation/workflow_block_engine.py
+++ b/skyvern/forge/sdk/experimentation/workflow_block_engine.py
@@ -419,6 +419,19 @@ async def effective_default_engine(workflow_permanent_id: str, organization_id:
return None
+async def unset_engine_routes_as_v1(workflow_permanent_id: str, organization_id: str) -> bool:
+ """Whether an unset block engine and skyvern-1.0 route alike in this workflow.
+
+ False when the workflow's birth cannot be read, although routing then still treats them alike: this errs
+ toward a caller comparing definitions seeing a change, so a cached script is regenerated, not reused stale.
+ """
+ cutoff = settings.TASK_V3_CHOSEN_ENGINE_CUTOFF
+ if cutoff is None or isinstance(app.EXPERIMENTATION_PROVIDER, NoOpExperimentationProvider):
+ return True
+ born_at = await _workflow_birth(workflow_permanent_id, organization_id)
+ return born_at is not None and not _born_at_or_after(born_at, cutoff)
+
+
def resolved_workflow_block_engine_arm_attribution(workflow_run_id: str | None) -> WorkflowBlockEngineArmAttribution:
"""The arm and the routing facts finalize-time telemetry can attribute to this run.
diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.py
index 311d3fd7e..e7030969c 100644
--- a/skyvern/forge/sdk/routes/agent_protocol.py
+++ b/skyvern/forge/sdk/routes/agent_protocol.py
@@ -5383,8 +5383,8 @@ async def get_workflow(
workflow_permanent_id=workflow_permanent_id,
organization_id=current_org.organization_id,
)
- workflow.effective_default_engine = await effective_default_engine(
- workflow_permanent_id, current_org.organization_id
+ workflow.set_effective_default_engine(
+ await effective_default_engine(workflow_permanent_id, current_org.organization_id)
)
return workflow
diff --git a/skyvern/forge/sdk/routes/code_samples.py b/skyvern/forge/sdk/routes/code_samples.py
index 79924d50e..1e32bede9 100644
--- a/skyvern/forge/sdk/routes/code_samples.py
+++ b/skyvern/forge/sdk/routes/code_samples.py
@@ -233,7 +233,6 @@ workflow_definition:
block_type: navigation
url: "{{website_url}}"
title: Fill_Out_Contact_Form
- engine: skyvern-1.0
navigation_goal: >-
Find the contact form. Fill out the contact us form and submit it. Your
goal is complete when the page says your message has been sent. In the
@@ -321,7 +320,6 @@ workflow_definition = {
"block_type": "navigation",
"url": "{{website_url}}",
"title": "Fill_Out_Contact_Form",
- "engine": "skyvern-1.0",
"navigation_goal": "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}",
"error_code_mapping": None,
"max_retries": 0,
@@ -405,7 +403,6 @@ const workflowDefinition = {
block_type: "navigation",
url: "{{website_url}}",
title: "Fill_Out_Contact_Form",
- engine: "skyvern-1.0",
navigation_goal: "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}",
error_code_mapping: null,
max_retries: 0,
@@ -483,7 +480,6 @@ workflow_definition:
block_type: navigation
url: "{{website_url}}"
title: Fill_Out_Contact_Form
- engine: skyvern-1.0
navigation_goal: >-
Find the contact form. Fill out the contact us form and submit it. Your
goal is complete when the page says your message has been sent. In the
@@ -570,7 +566,6 @@ updated_workflow_definition = {
"block_type": "navigation",
"url": "{{website_url}}",
"title": "Fill_Out_Contact_Form",
- "engine": "skyvern-1.0",
"navigation_goal": "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\n\nFill out required fields as best you can using the following information:\n{{name}}\n{{email}}\n{{additional_information}}",
"error_code_mapping": None,
"max_retries": 0,
@@ -653,7 +648,6 @@ const updatedWorkflowDefinition = {
block_type: "navigation",
url: "{{website_url}}",
title: "Fill_Out_Contact_Form",
- engine: "skyvern-1.0",
navigation_goal: "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}",
error_code_mapping: null,
max_retries: 0,
diff --git a/skyvern/forge/sdk/workflow/models/workflow.py b/skyvern/forge/sdk/workflow/models/workflow.py
index 68852ad46..6c0a3d8c1 100644
--- a/skyvern/forge/sdk/workflow/models/workflow.py
+++ b/skyvern/forge/sdk/workflow/models/workflow.py
@@ -5,10 +5,13 @@ from typing import Any, List
from pydantic import (
BaseModel,
Field,
+ PrivateAttr,
+ SerializerFunctionWrapHandler,
ValidationInfo,
computed_field,
field_serializer,
field_validator,
+ model_serializer,
model_validator,
)
from typing_extensions import Self, deprecated
@@ -266,6 +269,8 @@ class Workflow(BaseModel):
description="The engine a task block with no `engine` set runs on in this agent, or null when "
"engine routing decides it. Populated by the detail endpoint only.",
)
+ # Set by the detail GET; elsewhere the key is omitted, since a null would claim routing decides the engine.
+ _effective_default_engine_computed: bool = PrivateAttr(default=False)
original_created_by: str | None = Field(
default=None,
description="Who created the agent's first version. Populated by the list endpoint only.",
@@ -284,6 +289,18 @@ class Workflow(BaseModel):
def _mask_cdp_connect_headers(self, headers: dict[str, str] | None) -> dict[str, str] | None:
return mask_header_values(headers)
+ # No return annotation: pydantic would publish it as the response schema in place of the model's fields.
+ @model_serializer(mode="wrap")
+ def _omit_uncomputed_engine(self, handler: SerializerFunctionWrapHandler): # type: ignore[no-untyped-def]
+ data = handler(self)
+ if not self._effective_default_engine_computed:
+ data.pop("effective_default_engine", None)
+ return data
+
+ def set_effective_default_engine(self, engine: RunEngine | None) -> None:
+ self.effective_default_engine = engine
+ self._effective_default_engine_computed = True
+
created_at: datetime
modified_at: datetime
deleted_at: datetime | None = None
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py
index c1d102e9f..83456bfb2 100644
--- a/skyvern/forge/sdk/workflow/service.py
+++ b/skyvern/forge/sdk/workflow/service.py
@@ -120,10 +120,10 @@ from skyvern.forge.sdk.experimentation.transient_ui_capture import resolve_trans
from skyvern.forge.sdk.experimentation.workflow_block_engine import (
ARM_ATTRIBUTION_LOST,
WorkflowBlockEngineArmAttribution,
- effective_default_engine,
engine_arm_log_value,
resolve_workflow_block_engine_arm,
resolved_workflow_block_engine_arm_attribution,
+ unset_engine_routes_as_v1,
)
from skyvern.forge.sdk.forge_log import exception_log_fields
from skyvern.forge.sdk.models import Step, StepStatus
@@ -11157,7 +11157,7 @@ class WorkflowService:
current_definition: dict[str, Any] = {}
new_definition: dict[str, Any] = {}
if previous_valid_workflow:
- unset_engine_is_v1 = await effective_default_engine(workflow.workflow_permanent_id, organization_id) is None
+ unset_engine_is_v1 = await unset_engine_routes_as_v1(workflow.workflow_permanent_id, organization_id)
current_definition = _get_workflow_definition_core_data(
previous_valid_workflow.workflow_definition, unset_engine_is_v1=unset_engine_is_v1
)
diff --git a/skyvern/services/script_service.py b/skyvern/services/script_service.py
index caf032064..3a31e5776 100644
--- a/skyvern/services/script_service.py
+++ b/skyvern/services/script_service.py
@@ -56,6 +56,7 @@ from skyvern.forge.sdk.artifact.storage.base import get_download_retry_started_a
from skyvern.forge.sdk.core import skyvern_context
from skyvern.forge.sdk.core.hashing import diagnostic_fingerprint
from skyvern.forge.sdk.db.enums import TaskType, is_job_recipe_workflow_run_trigger_type
+from skyvern.forge.sdk.experimentation.workflow_block_engine import run_honors_chosen_engine
from skyvern.forge.sdk.models import Step, StepStatus
from skyvern.forge.sdk.schemas.files import FileInfo
from skyvern.forge.sdk.schemas.tasks import Task, TaskOutput, TaskStatus
@@ -1429,6 +1430,18 @@ def _resolve_original_block_engine(cache_key: str, workflow: Workflow, workflow_
return None
+def _script_block_engine(workflow: Workflow, label: str) -> RunEngine | None:
+ # In a run that honors chosen engines the helper's block carries the stored choice, pin or unset. Elsewhere
+ # unset routes exactly as the skyvern-1.0 these helpers used to set, so nothing changes before the cutoff.
+ context = skyvern_context.current()
+ if not run_honors_chosen_engine(context.workflow_run_id if context else None):
+ return None
+ for block in get_all_blocks(workflow.workflow_definition.blocks):
+ if block.label == label and isinstance(block, BaseTaskBlock):
+ return block.engine
+ return None
+
+
async def _fallback_to_ai_run(
block_type: BlockType,
cache_key: str,
@@ -2346,7 +2359,7 @@ async def run_task(
totp_identifier=totp_identifier,
totp_verification_url=totp_url,
include_action_history_in_verification=True,
- engine=RunEngine.skyvern_v1,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
model=model,
)
block_output = await task_block.execute_safe(
@@ -2947,7 +2960,7 @@ async def download(
totp_identifier=totp_identifier,
totp_verification_url=totp_url,
include_action_history_in_verification=True,
- engine=RunEngine.skyvern_v1,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
model=model,
download_suffix=download_suffix,
**destination_block_kwargs,
@@ -3035,6 +3048,7 @@ async def action(
block_validation_output = await _validate_and_get_output_parameter(label)
action_block = ActionBlock(
label=block_validation_output.label,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
output_parameter=block_validation_output.output_parameter,
task_type=TaskType.action,
url=url,
@@ -3127,6 +3141,7 @@ async def login(
block_validation_output = await _validate_and_get_output_parameter(label)
login_block = LoginBlock(
label=block_validation_output.label,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
output_parameter=block_validation_output.output_parameter,
url=url,
navigation_goal=prompt,
@@ -3208,6 +3223,7 @@ async def extract(
block_validation_output = await _validate_and_get_output_parameter(label)
extraction_block = ExtractionBlock(
label=block_validation_output.label,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
url=url,
data_extraction_goal=prompt,
max_steps_per_run=max_steps,
@@ -3315,6 +3331,7 @@ async def execute_validation(
block_validation_output = await _validate_and_get_output_parameter(label)
validation_block = ValidationBlock(
label=block_validation_output.label,
+ engine=_script_block_engine(block_validation_output.workflow, block_validation_output.label),
output_parameter=block_validation_output.output_parameter,
task_type=TaskType.validation,
complete_criterion=complete_criterion,
diff --git a/tests/unit/test_copilot_workflow_update.py b/tests/unit/test_copilot_workflow_update.py
index 8af2fb954..b17494225 100644
--- a/tests/unit/test_copilot_workflow_update.py
+++ b/tests/unit/test_copilot_workflow_update.py
@@ -36,6 +36,29 @@ from skyvern.schemas.runs import ProxyLocation
from skyvern.schemas.workflows import WorkflowCreateYAMLRequest, WorkflowStatus
from tests.unit.copilot_test_helpers import make_copilot_ctx
+
+async def test_a_copilot_round_trip_leaves_an_unset_block_engine_unset(monkeypatch: pytest.MonkeyPatch) -> None:
+ # Past the chosen-engine cutoff a written skyvern-1.0 is a pin, not the default an omitted engine runs.
+ blocks = [
+ {"block_type": "navigation", "label": "nav", "url": "https://example.com", "navigation_goal": "Go"},
+ {"block_type": "extraction", "label": "ex", "data_extraction_goal": "Read"},
+ {"block_type": "file_download", "label": "dl", "navigation_goal": "Download"},
+ {"block_type": "login", "label": "lg"},
+ ]
+ monkeypatch.setattr(
+ app.WORKFLOW_SERVICE, "get_workflow_by_permanent_id", AsyncMock(side_effect=WorkflowNotFound("wp"))
+ )
+ document = {"title": "t", "workflow_definition": {"version": 2, "parameters": [], "blocks": blocks}}
+ stored = await _process_workflow_yaml("w", "wp", "o", yaml.safe_dump(document))
+
+ copilot_yaml = workflow_yaml_module.workflow_to_copilot_yaml(stored)
+ applied = await _process_workflow_yaml("w", "wp", "o", copilot_yaml, settings_fallback_workflow=stored)
+
+ assert all("engine" not in block for block in yaml.safe_load(copilot_yaml)["workflow_definition"]["blocks"])
+ assert all("engine" not in block for block in applied.model_dump(mode="json")["workflow_definition"]["blocks"])
+
+
_SETTING_VALUES: dict[str, tuple[Any, Any]] = {
"is_saved_task": (True, False),
"description": ("Saved description", "Edited description"),
diff --git a/tests/unit/test_file_download_targets.py b/tests/unit/test_file_download_targets.py
index f1fef97fe..c23359a47 100644
--- a/tests/unit/test_file_download_targets.py
+++ b/tests/unit/test_file_download_targets.py
@@ -2047,6 +2047,7 @@ async def test_non_cached_script_download_threads_destination_into_single_block_
organization_id="organization-id",
browser_session_id="browser-session-id",
context=SimpleNamespace(parent_workflow_run_block_id="parent-block-id"),
+ workflow=SimpleNamespace(workflow_definition=SimpleNamespace(blocks=[])),
)
with (
diff --git a/tests/unit/test_login_block_missing_credential.py b/tests/unit/test_login_block_missing_credential.py
index a3b88e362..23b254268 100644
--- a/tests/unit/test_login_block_missing_credential.py
+++ b/tests/unit/test_login_block_missing_credential.py
@@ -201,6 +201,7 @@ async def test_preflight_passes_the_login_block_a_cached_script_builds() -> None
organization_id="o_test",
browser_session_id=None,
context=SimpleNamespace(parent_workflow_run_block_id=None),
+ workflow=SimpleNamespace(workflow_definition=SimpleNamespace(blocks=[])),
)
with (
patch.object(script_service.script_run_context_manager, "get_cached_fn", return_value=None),
diff --git a/tests/unit/test_mcp_legacy_manifest.py b/tests/unit/test_mcp_legacy_manifest.py
index b8e28ea6d..6b7e91ce7 100644
--- a/tests/unit/test_mcp_legacy_manifest.py
+++ b/tests/unit/test_mcp_legacy_manifest.py
@@ -10,8 +10,8 @@ from skyvern.cli.mcp_tools import mcp
from skyvern.cli.mcp_tools.instructions import DEFAULT_INSTRUCTIONS
from skyvern.cli.mcp_tools.scopes import MCPScope, apply_scope
-# Re-frozen for SKY-17181: the extension-mode evaluation guidance changed.
-DEFAULT_INSTRUCTIONS_SHA256 = "f2b0ac0fea44be39e5be84ec28617ad6fc9b6323003d1114c08d4dd7e9598d7f"
+# Re-frozen for SKY-17457: engine guidance omits the field by default and sets skyvern-1.0 only on request.
+DEFAULT_INSTRUCTIONS_SHA256 = "3b05238400b52f2120120403f80b2a8af9c487e41990b95efb5310ccd0376312"
# Digests snapshot each legacy tool's wire manifest: name, schema, description, annotations, _meta.
# New tool names are ignored; any change to a legacy tool fails.
diff --git a/tests/unit/test_mcp_workflow_guidance.py b/tests/unit/test_mcp_workflow_guidance.py
index 8a600f6e9..19bf0f73b 100644
--- a/tests/unit/test_mcp_workflow_guidance.py
+++ b/tests/unit/test_mcp_workflow_guidance.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import inspect
+from pathlib import Path
import pytest
@@ -17,6 +18,7 @@ from skyvern.cli.mcp_tools.workflow import (
skyvern_workflow_run,
skyvern_workflow_update,
)
+from skyvern.forge.sdk.routes import code_samples
def test_build_workflow_prompt_guides_text_prompt_defaults() -> None:
@@ -40,6 +42,28 @@ def test_mcp_instructions_guide_text_prompt_defaults() -> None:
assert "skyvern_observe" in mcp.instructions
+def test_workflow_authoring_sources_leave_the_block_engine_unset() -> None:
+ # Past TASK_V3_CHOSEN_ENGINE_CUTOFF an omitted engine is not skyvern-1.0 and a written one is a pin.
+ prompts_dir = Path(code_samples.__file__).resolve().parents[2] / "prompts" / "skyvern"
+ sources = {
+ "mcp instructions": mcp.instructions,
+ "build_workflow prompt": BUILD_WORKFLOW_CONTENT,
+ "knowledge base": (prompts_dir / "workflow_knowledge_base.txt").read_text(),
+ "pdf import prompt": (prompts_dir / "build-workflow-from-pdf.j2").read_text(),
+ "code samples": Path(code_samples.__file__).read_text(),
+ "skyvern skill": (
+ Path(mcp_common.__file__).resolve().parents[1] / "skills" / "skyvern" / "SKILL.md"
+ ).read_text(),
+ }
+ for name, text in sources.items():
+ for line in text.splitlines():
+ if "skyvern-1.0" in line:
+ assert "asks for" in line and "default" not in line, (name, line)
+ assert "engine 1.0" not in text and "1.0 blocks" not in text and "1.0 (default" not in text, name
+ for name in ("mcp instructions", "build_workflow prompt", "skyvern skill"):
+ assert "`engine: skyvern-1.0`" in sources[name], name
+
+
def test_workflow_create_guides_code_only_policy() -> None:
assert mcp_common.CODE_ONLY_SCHEMA_GUIDANCE in (skyvern_workflow_create.__doc__ or "")
diff --git a/tests/unit/test_request_logging.py b/tests/unit/test_request_logging.py
index 50903ca7e..6b448dc52 100644
--- a/tests/unit/test_request_logging.py
+++ b/tests/unit/test_request_logging.py
@@ -125,6 +125,10 @@ class TestIsSensitiveKey:
"cdp_connect_headers",
# One-time codes
"cached_totp",
+ # OAuth credentials
+ "client_secret",
+ "access_token",
+ "refresh_token",
],
)
def test_sensitive_keys_are_redacted(self, key: str) -> None:
diff --git a/tests/unit/test_script_service_fallback_engine.py b/tests/unit/test_script_service_fallback_engine.py
index 467a6e863..0703013af 100644
--- a/tests/unit/test_script_service_fallback_engine.py
+++ b/tests/unit/test_script_service_fallback_engine.py
@@ -16,11 +16,18 @@ import pytest
from skyvern.config import settings
from skyvern.forge.sdk.core.skyvern_context import SkyvernContext
from skyvern.forge.sdk.schemas.tasks import TaskStatus
-from skyvern.forge.sdk.workflow.models.block import TaskBlock, takes_default_engine, v3_ab_ineligibility_reason
+from skyvern.forge.sdk.workflow.models.block import (
+ BaseTaskBlock,
+ Block,
+ TaskBlock,
+ takes_default_engine,
+ v3_ab_ineligibility_reason,
+)
from skyvern.forge.sdk.workflow.models.parameter import OutputParameter, ParameterType
from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowDefinition
+from skyvern.forge.sdk.workflow.workflow_definition_converter import convert_workflow_definition
from skyvern.schemas.runs import RunEngine
-from skyvern.schemas.workflows import BlockType
+from skyvern.schemas.workflows import BlockType, WorkflowDefinitionYAML
from skyvern.services import script_service
from skyvern.webeye.actions.action_types import ActionType
from skyvern.webeye.actions.actions import Action, ActionStatus
@@ -215,6 +222,88 @@ async def test_fallback_of_an_unset_engine_block_follows_the_chosen_engine_cutof
assert _fallback_task_block(app).engine == expected
+_UNCACHED_HELPER_CALLS = {
+ "navigation": lambda: script_service.run_task(prompt="p", label="navigation"),
+ "file_download": lambda: script_service.download(prompt="p", label="file_download"),
+ "action": lambda: script_service.action(prompt="p", label="action"),
+ "login": lambda: script_service.login(prompt="p", label="login"),
+ "extraction": lambda: script_service.extract(prompt="p", label="extraction"),
+ "validation": lambda: script_service.execute_validation("done", None, None, label="validation"),
+}
+
+
+class _Built(Exception):
+ pass
+
+
+_CUTOFF = datetime(2026, 10, 1, tzinfo=timezone.utc)
+
+
+ ("cutoff", "born_at"),
+ [
+ pytest.param(_CUTOFF, datetime(2026, 10, 2, tzinfo=timezone.utc), id="past_cutoff"),
+ pytest.param(_CUTOFF, datetime(2026, 9, 30, tzinfo=timezone.utc), id="born_before_cutoff"),
+ pytest.param(None, datetime(2026, 10, 2, tzinfo=timezone.utc), id="cutoff_unset"),
+ ],
+)
[email protected]("stored_engine", [None, RunEngine.skyvern_v1.value, RunEngine.skyvern_v3.value])
[email protected]("block_type", list(_UNCACHED_HELPER_CALLS))
+async def test_an_uncached_script_block_runs_where_its_stored_block_would_only_past_the_cutoff(
+ monkeypatch: pytest.MonkeyPatch,
+ block_type: str,
+ stored_engine: str | None,
+ cutoff: datetime | None,
+ born_at: datetime,
+) -> None:
+ monkeypatch.setattr(settings, "TASK_V3_DEFAULT_ENGINE_WORKFLOW_CUTOFF", None)
+ monkeypatch.setattr(settings, "TASK_V3_CHOSEN_ENGINE_CUTOFF", cutoff)
+ goal = {"validation": "complete_criterion", "extraction": "data_extraction_goal"}.get(block_type, "navigation_goal")
+ stored_block = {"block_type": block_type, "label": block_type, goal: "p"}
+ if stored_engine is not None:
+ stored_block["engine"] = stored_engine
+ # A second block left unset makes the run take the default engine, so a skyvern-1.0 pin is honored.
+ unset_block = {"block_type": "navigation", "label": "unset", "navigation_goal": "p"}
+ definition = convert_workflow_definition(
+ WorkflowDefinitionYAML.model_validate({"parameters": [], "blocks": [stored_block, unset_block]}), "w_test"
+ )
+ workflow = _make_workflow(definition.blocks)
+ stored = definition.blocks[0]
+ context = _make_context()
+ await resolve_arm(
+ context,
+ FakeExperimentationProvider(),
+ workflow_run_id="wr_test",
+ ineligibility_reason=v3_ab_ineligibility_reason(workflow.workflow_definition.blocks, is_script_run=True),
+ takes_default_engine=takes_default_engine(workflow.workflow_definition.blocks),
+ first_version_created_at=born_at,
+ )
+ ran_on: list[tuple[RunEngine, RunEngine]] = []
+
+ async def capture(self: Block, **_: object) -> None:
+ assert isinstance(self, BaseTaskBlock) and isinstance(stored, BaseTaskBlock)
+ ran_on.append((self.resolve_engine("wr_test"), stored.resolve_engine("wr_test")))
+ raise _Built
+
+ with (
+ patch(f"{MODULE}.app", _make_app(workflow)),
+ patch(f"{MODULE}.skyvern_context.current", return_value=context),
+ patch(f"{MODULE}.skyvern_context.ensure_context", return_value=context),
+ patch(f"{MODULE}.script_run_context_manager.get_cached_fn", return_value=None),
+ patch.object(Block, "execute_safe", capture),
+ pytest.raises(_Built),
+ ):
+ await _UNCACHED_HELPER_CALLS[block_type]()
+
+ [(helper_engine, stored_block_engine)] = ran_on
+ if cutoff is not None and born_at > cutoff:
+ assert helper_engine == stored_block_engine
+ else:
+ # Outside the cutoff the helpers keep main's behaviour, where every stored engine ran on skyvern_v1.
+ assert helper_engine == RunEngine.skyvern_v1
+
+
def test_resolver_finds_loop_nested_block_engine() -> None:
# A cached block inside a for-loop must keep its configured engine on fallback; the lookup
# is recursive (labels are globally unique, nested included).
diff --git a/tests/unit/test_update_workflow_route.py b/tests/unit/test_update_workflow_route.py
index 55763d648..e66d16dd4 100644
--- a/tests/unit/test_update_workflow_route.py
+++ b/tests/unit/test_update_workflow_route.py
@@ -10,6 +10,7 @@ from __future__ import annotations
import datetime as dt
import importlib
+from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from fastapi import FastAPI, Request
@@ -20,6 +21,8 @@ from skyvern.exceptions import SkyvernHTTPException
from skyvern.forge.sdk.routes.routers import base_router
from skyvern.forge.sdk.schemas.organizations import Organization
from skyvern.forge.sdk.services import org_auth_service
+from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowDefinition
+from skyvern.schemas.runs import RunEngine
ORG_ID = "o_test"
@@ -58,3 +61,51 @@ def test_update_workflow_without_definition_returns_422(client: TestClient) -> N
assert resp.status_code == 422, resp.text
assert "json" in resp.json()["detail"].lower()
+
+
+def _stored_workflow() -> Workflow:
+ now = dt.datetime.now(dt.timezone.utc)
+ return Workflow(
+ workflow_id="w_test",
+ organization_id=ORG_ID,
+ title="t",
+ workflow_permanent_id="wpid_test",
+ version=1,
+ is_saved_task=False,
+ workflow_definition=WorkflowDefinition(parameters=[], blocks=[]),
+ created_at=now,
+ modified_at=now,
+ )
+
+
[email protected]("computed", [None, RunEngine.skyvern_v3])
+def test_only_the_detail_get_carries_the_effective_default_engine(
+ client: TestClient, computed: RunEngine | None
+) -> None:
+ # A null means routing decides the engine, so a response that never computed it must omit the key.
+ mock_app = MagicMock()
+ mock_app.WORKFLOW_SERVICE.get_workflow_by_permanent_id = AsyncMock(return_value=_stored_workflow())
+ mock_app.WORKFLOW_SERVICE.get_workflow_versions_by_permanent_id = AsyncMock(return_value=[_stored_workflow()])
+ mock_app.WORKFLOW_SERVICE.create_workflow_from_request = AsyncMock(return_value=_stored_workflow())
+ mock_app.WORKFLOW_SERVICE.get_workflows_by_organization_id = AsyncMock(return_value=[_stored_workflow()])
+ mock_app.DATABASE.workflows.is_workflow_copilot_authored = AsyncMock(return_value=False)
+ with (
+ patch("skyvern.forge.sdk.routes.agent_protocol.app", mock_app),
+ patch("skyvern.forge.sdk.routes.agent_protocol.effective_default_engine", AsyncMock(return_value=computed)),
+ ):
+ detail = client.get("/v1/workflows/wpid_test")
+ versions = client.get("/v1/workflows/wpid_test/versions")
+ listed = client.get("/v1/workflows")
+ saved = client.post(
+ "/v1/workflows/wpid_test",
+ json={"yaml_definition": "title: t\nworkflow_definition:\n parameters: []\n blocks: []\n"},
+ )
+
+ assert detail.status_code == 200, detail.text
+ assert detail.json()["effective_default_engine"] == (computed and computed.value)
+ assert versions.status_code == 200, versions.text
+ assert "effective_default_engine" not in versions.json()[0]
+ assert listed.status_code == 200, listed.text
+ assert "effective_default_engine" not in listed.json()[0]
+ assert saved.status_code == 200, saved.text
+ assert "effective_default_engine" not in saved.json()
diff --git a/tests/unit/test_workflow_browser_profile_id.py b/tests/unit/test_workflow_browser_profile_id.py
index 2512f68c5..b17fbef52 100644
--- a/tests/unit/test_workflow_browser_profile_id.py
+++ b/tests/unit/test_workflow_browser_profile_id.py
@@ -1,5 +1,7 @@
from __future__ import annotations
+import copy
+import pickle
from collections.abc import Generator
from datetime import datetime, timezone
from types import SimpleNamespace
@@ -43,6 +45,14 @@ def test_workflow_pydantic_accepts_browser_profile_id() -> None:
assert workflow.browser_profile_id == "bp_abc123"
+def test_default_workflow_deep_copies_and_pickles() -> None:
+ # Copilot block runs deep-copy the stored workflow, so every field default must be copyable.
+ workflow = _make_workflow()
+ assert copy.deepcopy(workflow) == workflow
+ assert workflow.model_copy(deep=True) == workflow
+ assert pickle.loads(pickle.dumps(workflow)) == workflow
+
+
def test_workflow_create_yaml_request_defaults_to_none() -> None:
request = WorkflowCreateYAMLRequest(
title="test",
diff --git a/tests/unit/workflow/test_cache_invalidation.py b/tests/unit/workflow/test_cache_invalidation.py
index ea078100f..df8b7829b 100644
--- a/tests/unit/workflow/test_cache_invalidation.py
+++ b/tests/unit/workflow/test_cache_invalidation.py
@@ -254,10 +254,15 @@ def _as_the_previous_image_stored_it(definition: WorkflowDefinition) -> dict:
async def _resave(
- stored: dict, resaved: WorkflowDefinition, monkeypatch: pytest.MonkeyPatch, *, born_at: datetime
+ stored: dict,
+ resaved: WorkflowDefinition,
+ monkeypatch: pytest.MonkeyPatch,
+ *,
+ born_at: datetime | None,
+ cutoff: datetime | None = _CUTOFF,
) -> AsyncMock:
"""Save ``resaved`` over a workflow whose previous version holds ``stored``; returns the cache clear."""
- monkeypatch.setattr(settings, "TASK_V3_CHOSEN_ENGINE_CUTOFF", _CUTOFF)
+ monkeypatch.setattr(settings, "TASK_V3_CHOSEN_ENGINE_CUTOFF", cutoff)
now = datetime.now(timezone.utc)
previous = Workflow(
workflow_id="w_1",
@@ -287,6 +292,14 @@ async def _resave(
return clear_groups
+ ("born_at", "cutoff"),
+ [
+ (_CUTOFF - timedelta(days=30), _CUTOFF),
+ # No cutoff set: the two route alike whatever the birth lookup returns.
+ (None, None),
+ ],
+)
@pytest.mark.parametrize(
"nav_engine",
[
@@ -298,12 +311,12 @@ async def _resave(
)
@pytest.mark.asyncio
async def test_an_unchanged_resave_of_a_previously_stored_definition_keeps_its_cached_scripts(
- monkeypatch: pytest.MonkeyPatch, nav_engine: str | None
+ monkeypatch: pytest.MonkeyPatch, nav_engine: str | None, born_at: datetime | None, cutoff: datetime | None
) -> None:
resaved = convert_workflow_definition(_yaml_definition(nav_engine), "w_1")
stored = _as_the_previous_image_stored_it(resaved)
- clear_groups = await _resave(stored, resaved, monkeypatch, born_at=_CUTOFF - timedelta(days=30))
+ clear_groups = await _resave(stored, resaved, monkeypatch, born_at=born_at, cutoff=cutoff)
clear_groups.assert_not_awaited()
if nav_engine is not None:
@@ -311,15 +324,24 @@ async def test_an_unchanged_resave_of_a_previously_stored_definition_keeps_its_c
assert resaved.model_dump(mode="json") == stored
+ "born_at",
+ [
+ _CUTOFF + timedelta(days=1),
+ # The birth lookup failed: the workflow may be past the cutoff, so the two stay distinct.
+ None,
+ ],
+)
@pytest.mark.asyncio
-async def test_past_the_cutoff_switching_a_legacy_pin_to_default_is_a_change(monkeypatch: pytest.MonkeyPatch) -> None:
+async def test_past_the_cutoff_switching_a_legacy_pin_to_default_is_a_change(
+ monkeypatch: pytest.MonkeyPatch, born_at: datetime | None
+) -> None:
# Unset runs on v3 there and skyvern-1.0 is an explicit pin, so the cached script must be cleared;
# the engine-inert blocks around it still compare equal.
stored = convert_workflow_definition(_yaml_definition(RunEngine.skyvern_v1.value), "w_1").model_dump(mode="json")
resaved = convert_workflow_definition(_yaml_definition(None), "w_1")
- born_after = _CUTOFF + timedelta(days=1)
- clear_groups = await _resave(stored, resaved, monkeypatch, born_at=born_after)
+ clear_groups = await _resave(stored, resaved, monkeypatch, born_at=born_at)
clear_groups.assert_awaited_once()
assert clear_groups.await_args.kwargs["plan"].label == "nav"