Skip to content

Automate browser based workflows with AI

Default new navigation blocks to no model override and drop empty model names on save (#8979)

Shuchang Zheng016df8c71f7b
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
index ae051aeaa..6f18005b4 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
@@ -37,7 +37,7 @@ export const navigationNodeDefaultData: NavigationNodeData = {
completeCriterion: "",
terminateCriterion: "",
errorCodeMapping: "null",
- model: { model_name: "" },
+ model: null,
engine: null,
maxRetries: null,
maxStepsOverride: null,
diff --git a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.test.ts b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.test.ts
index d9b53c145..142425ff8 100644
--- a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.test.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.test.ts
@@ -521,3 +521,30 @@ describe("block engine load and save", () => {
]);
});
});
+
+describe("block model override on save", () => {
+ test("a new navigation block saves no model override", () => {
+ const node = createNode({ id: "n1" }, "navigation", "Go to page");
+
+ expect(getWorkflowBlocks([node], [])[0]).toMatchObject({ model: null });
+ });
+
+ test.each([
+ ["an empty model name is dropped", { model_name: "" }, null],
+ [
+ "a chosen model is kept",
+ { model_name: "gemini-3-flash" },
+ { model_name: "gemini-3-flash" },
+ ],
+ ])("%s", (_name, stored, expected) => {
+ const { nodes, edges } = getElements(
+ [{ ...minimalTaskBlock(), model: stored } as WorkflowBlock],
+ SETTINGS,
+ true,
+ );
+
+ expect(getWorkflowBlocks(nodes, edges)[0]).toMatchObject({
+ model: expected,
+ });
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
index 220ea8681..7aa0c367b 100644
--- a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
@@ -46,6 +46,7 @@ import {
type ConditionalBlock,
type ForLoopBlock,
type WhileLoopBlock,
+ type WorkflowModel,
isNestedLoopWorkflowBlock,
} from "../types/workflowTypes";
import {
@@ -3325,6 +3326,13 @@ function findNextBlockLabel(
return null;
}
+// Navigation blocks used to default to `{ model_name: "" }`, which is not an override.
+function blockModelOverride(
+ model: WorkflowModel | null | undefined,
+): WorkflowModel | null {
+ return model?.model_name ? model : null;
+}
+
function getWorkflowBlock(
node: WorkflowBlockNode,
nodes: Array<AppNode>,
@@ -3337,7 +3345,7 @@ function getWorkflowBlock(
label: node.data.label,
continue_on_failure: node.data.continueOnFailure,
next_loop_on_failure: node.data.nextLoopOnFailure,
- model: node.data.model,
+ model: blockModelOverride(node.data.model),
next_block_label: nextBlockLabel,
ignore_workflow_system_prompt:
node.data.ignoreWorkflowSystemPrompt ?? false,
@@ -5082,7 +5090,7 @@ function convertBlocksToBlockYAML(
url: block.url,
title: block.title,
...blockEngineYAML(block, effectiveDefaultEngine),
- model: block.model,
+ model: blockModelOverride(block.model),
navigation_goal: block.navigation_goal,
error_code_mapping: block.error_code_mapping,
max_retries: block.max_retries,
@@ -5398,7 +5406,7 @@ function convertBlocksToBlockYAML(
const blockYaml: WebSearchBlockYAML = {
...base,
block_type: "web_search",
- model: block.model,
+ model: blockModelOverride(block.model),
query: block.query,
provider: block.provider,
num_results: block.num_results,