Skip to content

Automate browser based workflows with AI

fix: preserve run_with mode when rerunning a workflow (#5053)

pedrohsdb720bbeaaf9dc
diff --git a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
index 51fda2598..8cc4b745d 100644
--- a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
+++ b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
@@ -119,6 +119,7 @@ type Props = {
cdpAddress: string | null;
maxScreenshotScrolls: number | null;
extraHttpHeaders: Record<string, string> | null;
+ runWith: string | null;
};
};
@@ -264,9 +265,14 @@ function transformToWorkflowRunRequest(
return transformed;
}
+const VALID_RUN_WITH = new Set(["agent", "code", "code_v2"]);
+
function deriveRunWith(
workflow?: WorkflowApiResponse,
+ override?: string | null,
): "agent" | "code" | "code_v2" {
+ if (override && VALID_RUN_WITH.has(override))
+ return override as "agent" | "code" | "code_v2";
if (workflow?.run_with === "code_v2") return "code_v2";
if (workflow?.adaptive_caching && workflow?.run_with === "code")
return "code_v2";
@@ -317,7 +323,7 @@ function RunWorkflowForm({
extraHttpHeaders: initialSettings.extraHttpHeaders
? JSON.stringify(initialSettings.extraHttpHeaders)
: null,
- runWith: deriveRunWith(workflow),
+ runWith: deriveRunWith(workflow, initialSettings.runWith),
aiFallback: workflow?.ai_fallback ?? true,
},
});
@@ -427,7 +433,7 @@ function RunWorkflowForm({
extraHttpHeaders: initialSettings.extraHttpHeaders
? JSON.stringify(initialSettings.extraHttpHeaders)
: null,
- runWith: deriveRunWith(workflow),
+ runWith: deriveRunWith(workflow, initialSettings.runWith),
aiFallback: workflow?.ai_fallback ?? true,
});
setIsFormReset(true);
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
index 300fd4f7a..e475cba8e 100644
--- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
+++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
@@ -452,6 +452,7 @@ function WorkflowRun() {
proxyLocation,
webhookCallbackUrl: workflowRun?.webhook_callback_url ?? "",
maxScreenshotScrolls,
+ runWith: workflowRun?.run_with,
}}
>
<PlayIcon className="mr-2 h-4 w-4" />
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRunParameters.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRunParameters.tsx
index 72660a33d..081d3afb7 100644
--- a/skyvern-frontend/src/routes/workflows/WorkflowRunParameters.tsx
+++ b/skyvern-frontend/src/routes/workflows/WorkflowRunParameters.tsx
@@ -42,6 +42,8 @@ function WorkflowRunParameters() {
? (location.state.extraHttpHeaders as Record<string, string>)
: null;
+ const runWith = (location.state?.runWith as string) ?? null;
+
const initialValues = getInitialValues(location, workflowParameters ?? []);
if (isFetching) {
@@ -77,6 +79,7 @@ function WorkflowRunParameters() {
extraHttpHeaders:
extraHttpHeaders ?? workflow.extra_http_headers ?? null,
cdpAddress: null,
+ runWith,
}}
/>
);