Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Report element-tree share and actual drop count when a prompt exceeds the token ceiling (SKY-12350) (#7820)
Aaron Perezbfb0faf9cab9
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.jsonindex 4beb2e654..96a2bc976 100644--- a/docs/api-reference/openapi.json+++ b/docs/api-reference/openapi.json@@ -1440,6 +1440,7 @@"description": "Invalid tag key or value"}},+ "x-hidden": true,"x-fern-sdk-method-name": "apply_run_tags"},"get": {@@ -1508,6 +1509,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_run_tags"}},@@ -1592,6 +1594,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "delete_run_tag"}},@@ -1713,6 +1716,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_run_tag_history"}},@@ -1770,6 +1774,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "list_tag_keys"}},@@ -1840,6 +1845,7 @@"description": "Description too long"}},+ "x-hidden": true,"x-fern-sdk-method-name": "update_tag_key"},"delete": {@@ -1908,6 +1914,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "delete_tag_key"}},@@ -1983,6 +1990,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "list_tag_values"},"post": {@@ -2040,6 +2048,7 @@"description": "Invalid key, value, or color"}},+ "x-hidden": true,"x-fern-sdk-method-name": "create_tag_value"}},@@ -2113,6 +2122,7 @@"description": "Invalid palette color"}},+ "x-hidden": true,"x-fern-sdk-method-name": "update_tag_value"},"delete": {@@ -2191,6 +2201,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "delete_tag_value"}},@@ -2267,6 +2278,7 @@"description": "Invalid value"}},+ "x-hidden": true,"x-fern-sdk-method-name": "rename_tag_value"}},@@ -2606,6 +2618,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_run_tag_suggestions"}},@@ -4843,6 +4856,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "list_custom_llms"},"post": {@@ -4904,6 +4918,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "create_custom_llm"}},@@ -4978,6 +4993,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "update_custom_llm"},"delete": {@@ -5040,6 +5056,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "delete_custom_llm"}},@@ -5309,6 +5326,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "create_script"},"get": {@@ -5396,6 +5414,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_scripts"}},@@ -5463,6 +5482,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_script"}},@@ -5540,6 +5560,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "deploy_script"}},@@ -5604,7 +5625,8 @@}}}- }+ },+ "x-hidden": true}},"/v1/sdk/run_action": {@@ -5938,6 +5960,7 @@"description": "Invalid tag key or value"}},+ "x-hidden": true,"x-fern-sdk-method-name": "apply_workflow_tags"},"get": {@@ -6006,6 +6029,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_workflow_tags"}},@@ -6090,6 +6114,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "delete_workflow_tag"}},@@ -6211,6 +6236,7 @@}}},+ "x-hidden": true,"x-fern-sdk-method-name": "get_workflow_tag_history"}},diff --git a/skyvern-frontend/src/components/RowActions.test.tsx b/skyvern-frontend/src/components/RowActions.test.tsxnew file mode 100644index 000000000..67f6b496b--- /dev/null+++ b/skyvern-frontend/src/components/RowActions.test.tsx@@ -0,0 +1,157 @@+// @vitest-environment jsdom++import type { ReactNode } from "react";+import { fireEvent, render, screen, within } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";++// Flatten both Radix menu families so each door's items render inline and are+// clickable; the doors stay distinguishable via testids on the menu roots.+vi.mock("@/components/ui/dropdown-menu", () => {+ const Pass = ({ children }: { children?: ReactNode }) => <>{children}</>;+ const Item = ({+ children,+ onSelect,+ disabled,+ className,+ }: {+ children?: ReactNode;+ onSelect?: () => void;+ disabled?: boolean;+ className?: string;+ }) => (+ <button disabled={disabled} onClick={onSelect} className={className}>+ {children}+ </button>+ );+ return {+ DropdownMenu: ({ children }: { children?: ReactNode }) => (+ <div data-testid="kebab-door">{children}</div>+ ),+ DropdownMenuTrigger: Pass,+ DropdownMenuContent: Pass,+ DropdownMenuItem: Item,+ DropdownMenuLabel: Pass,+ DropdownMenuSeparator: () => null,+ DropdownMenuSub: Pass,+ DropdownMenuSubTrigger: Pass,+ DropdownMenuSubContent: Pass,+ };+});++vi.mock("@/components/ui/context-menu", () => {+ const Pass = ({ children }: { children?: ReactNode }) => <>{children}</>;+ const Item = ({+ children,+ onSelect,+ disabled,+ className,+ }: {+ children?: ReactNode;+ onSelect?: () => void;+ disabled?: boolean;+ className?: string;+ }) => (+ <button disabled={disabled} onClick={onSelect} className={className}>+ {children}+ </button>+ );+ return {+ ContextMenu: ({ children }: { children?: ReactNode }) => (+ <div data-testid="context-door">{children}</div>+ ),+ ContextMenuTrigger: Pass,+ ContextMenuContent: Pass,+ ContextMenuItem: Item,+ ContextMenuLabel: Pass,+ ContextMenuSeparator: () => null,+ ContextMenuSub: Pass,+ ContextMenuSubTrigger: Pass,+ ContextMenuSubContent: Pass,+ };+});++vi.mock("@/components/ui/tooltip", () => {+ const Pass = ({ children }: { children?: ReactNode }) => <>{children}</>;+ return {+ Tooltip: Pass,+ TooltipProvider: Pass,+ TooltipTrigger: Pass,+ TooltipContent: () => null,+ };+});++import {+ RowActionsContextMenu,+ RowActionsKebab,+ type RowActionItem,+} from "./RowActions";++function buildItems(handlers: {+ onOpen: () => void;+ onYaml: () => void;+ onDelete: () => void;+}): Array<RowActionItem> {+ return [+ { kind: "item", label: "Open", onSelect: handlers.onOpen },+ { kind: "separator" },+ {+ kind: "sub",+ label: "Export",+ items: [{ label: "YAML", onSelect: handlers.onYaml }],+ },+ {+ kind: "item",+ label: "Delete",+ destructive: true,+ onSelect: handlers.onDelete,+ },+ ];+}++function renderDoors(items: Array<RowActionItem>) {+ return render(+ <>+ <RowActionsKebab items={items} ariaLabel="Actions for Row 1" />+ <RowActionsContextMenu items={items}>+ <div>row</div>+ </RowActionsContextMenu>+ </>,+ );+}++describe("RowActions", () => {+ it("renders one action set through both the kebab and the context menu", () => {+ renderDoors(+ buildItems({ onOpen: vi.fn(), onYaml: vi.fn(), onDelete: vi.fn() }),+ );++ const kebab = screen.getByTestId("kebab-door");+ const context = screen.getByTestId("context-door");+ for (const label of ["Open", "Export", "YAML", "Delete"]) {+ expect(within(kebab).getByText(label)).toBeTruthy();+ expect(within(context).getByText(label)).toBeTruthy();+ }+ expect(within(kebab).getByLabelText("Actions for Row 1")).toBeTruthy();+ });++ it("fires the shared handler from either door and styles destructive items", () => {+ const onOpen = vi.fn();+ const onYaml = vi.fn();+ const onDelete = vi.fn();+ renderDoors(buildItems({ onOpen, onYaml, onDelete }));++ const kebab = screen.getByTestId("kebab-door");+ const context = screen.getByTestId("context-door");+ fireEvent.click(within(kebab).getByText("Open"));+ fireEvent.click(within(context).getByText("Open"));+ expect(onOpen).toHaveBeenCalledTimes(2);++ fireEvent.click(within(kebab).getByText("YAML"));+ expect(onYaml).toHaveBeenCalledTimes(1);+ expect(within(kebab).getByText("Delete").className).toContain(+ "text-destructive",+ );+ fireEvent.click(within(context).getByText("Delete"));+ expect(onDelete).toHaveBeenCalledTimes(1);+ });+});diff --git a/skyvern-frontend/src/components/RowActions.tsx b/skyvern-frontend/src/components/RowActions.tsxnew file mode 100644index 000000000..e6ff435d3--- /dev/null+++ b/skyvern-frontend/src/components/RowActions.tsx@@ -0,0 +1,270 @@+import * as React from "react";+import { DotsHorizontalIcon } from "@radix-ui/react-icons";++import { Button } from "@/components/ui/button";+import {+ ContextMenu,+ ContextMenuContent,+ ContextMenuItem,+ ContextMenuLabel,+ ContextMenuSeparator,+ ContextMenuSub,+ ContextMenuSubContent,+ ContextMenuSubTrigger,+ ContextMenuTrigger,+} from "@/components/ui/context-menu";+import { DialogTrigger } from "@/components/ui/dialog";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { cn } from "@/util/utils";++// One action set, three doors (SKY-12955): a surface defines its row actions+// once and renders them through both the always-visible kebab and the+// right-click accelerator, so the two menus can't drift. The third door (bulk+// selection -> SelectionBar) stays separate; kebabs should yield to it while a+// selection is active.+type RowActionItem =+ | {+ kind: "item";+ label: React.ReactNode;+ icon?: React.ReactNode;+ onSelect?: () => void;+ destructive?: boolean;+ disabled?: boolean;+ // Wraps the item in a DialogTrigger so a confirm dialog owned by an+ // ancestor <Dialog> opens reliably from either menu.+ dialogTrigger?: boolean;+ }+ | { kind: "note"; label: React.ReactNode }+ | { kind: "separator" }+ | {+ kind: "sub";+ label: React.ReactNode;+ icon?: React.ReactNode;+ disabled?: boolean;+ // Plain nested actions and/or a door-agnostic panel (e.g. a Command).+ items?: Array<{ label: React.ReactNode; onSelect: () => void }>;+ content?: React.ReactNode;+ contentClassName?: string;+ onOpenChange?: (open: boolean) => void;+ };++type MenuKit = {+ Item: React.ComponentType<{+ className?: string;+ disabled?: boolean;+ onSelect?: (event: Event) => void;+ children?: React.ReactNode;+ }>;+ Label: React.ComponentType<{+ className?: string;+ children?: React.ReactNode;+ }>;+ Separator: React.ComponentType<{ className?: string }>;+ Sub: React.ComponentType<{+ onOpenChange?: (open: boolean) => void;+ children?: React.ReactNode;+ }>;+ SubTrigger: React.ComponentType<{+ disabled?: boolean;+ children?: React.ReactNode;+ }>;+ SubContent: React.ComponentType<{+ className?: string;+ children?: React.ReactNode;+ }>;+};++const dropdownKit: MenuKit = {+ Item: DropdownMenuItem,+ Label: DropdownMenuLabel,+ Separator: DropdownMenuSeparator,+ Sub: DropdownMenuSub,+ SubTrigger: DropdownMenuSubTrigger,+ SubContent: DropdownMenuSubContent,+};++const contextKit: MenuKit = {+ Item: ContextMenuItem,+ Label: ContextMenuLabel,+ Separator: ContextMenuSeparator,+ Sub: ContextMenuSub,+ SubTrigger: ContextMenuSubTrigger,+ SubContent: ContextMenuSubContent,+};++function RowActionMenuItems({+ items,+ kit,+}: {+ items: Array<RowActionItem>;+ kit: MenuKit;+}) {+ return (+ <>+ {items.map((item, index) => {+ switch (item.kind) {+ case "separator":+ return <kit.Separator key={index} />;+ case "note":+ return (+ <kit.Label+ key={index}+ className="text-xs font-normal text-muted-foreground"+ >+ {item.label}+ </kit.Label>+ );+ case "sub":+ return (+ <kit.Sub key={index} onOpenChange={item.onOpenChange}>+ <kit.SubTrigger disabled={item.disabled}>+ {item.icon}+ {item.label}+ </kit.SubTrigger>+ <kit.SubContent className={item.contentClassName}>+ {item.content}+ {item.items?.map((subItem, subIndex) => (+ <kit.Item+ key={subIndex}+ onSelect={() => subItem.onSelect()}+ >+ {subItem.label}+ </kit.Item>+ ))}+ </kit.SubContent>+ </kit.Sub>+ );+ case "item": {+ const { onSelect } = item;+ const menuItem = (+ <kit.Item+ disabled={item.disabled}+ onSelect={onSelect ? () => onSelect() : undefined}+ className={cn(+ item.destructive && "text-destructive focus:text-destructive",+ )}+ >+ {item.icon}+ {item.label}+ </kit.Item>+ );+ return (+ <React.Fragment key={index}>+ {item.dialogTrigger ? (+ <DialogTrigger asChild>{menuItem}</DialogTrigger>+ ) : (+ menuItem+ )}+ </React.Fragment>+ );+ }+ }+ })}+ </>+ );+}++type RowActionsKebabProps = {+ items: Array<RowActionItem>;+ // e.g. "Actions for {row name}" — the kebab is icon-only.+ ariaLabel: string;+ className?: string;+};++// Click handlers stop propagation because the kebab sits inside rows whose+// cells navigate on click (portaled menu clicks still bubble in the React tree).+function RowActionsKebab({+ items,+ ariaLabel,+ className,+}: RowActionsKebabProps) {+ return (+ <DropdownMenu modal={false}>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="icon"+ aria-label={ariaLabel}+ className={cn(+ "text-muted-foreground hover:text-foreground",+ className,+ )}+ onClick={(event) => event.stopPropagation()}+ >+ <DotsHorizontalIcon className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ </TooltipTrigger>+ <TooltipContent>Actions</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <DropdownMenuContent+ align="end"+ className="w-56"+ onClick={(event) => event.stopPropagation()}+ >+ <RowActionMenuItems items={items} kit={dropdownKit} />+ </DropdownMenuContent>+ </DropdownMenu>+ );+}++type RowActionsContextMenuProps = {+ items: Array<RowActionItem>;+ onOpenChange?: (open: boolean) => void;+ children: React.ReactNode;+};++function RowActionsContextMenu({+ items,+ onOpenChange,+ children,+}: RowActionsContextMenuProps) {+ const [menuOpen, setMenuOpen] = React.useState(false);+ // Keep the row highlighted while its context menu is open (the cursor leaves+ // it). Children.only throws clearly if the trigger wraps more than one node.+ const child = React.Children.only(children) as React.ReactElement<{+ className?: string;+ "data-row-active"?: string;+ }>;+ return (+ <ContextMenu+ onOpenChange={(open) => {+ setMenuOpen(open);+ onOpenChange?.(open);+ }}+ >+ <ContextMenuTrigger asChild>+ {React.cloneElement(child, {+ className: cn(child.props.className, "data-[row-active]:bg-muted/50"),+ "data-row-active": menuOpen ? "" : undefined,+ })}+ </ContextMenuTrigger>+ <ContextMenuContent className="w-56">+ <RowActionMenuItems items={items} kit={contextKit} />+ </ContextMenuContent>+ </ContextMenu>+ );+}++export { RowActionsContextMenu, RowActionsKebab };+export type { RowActionItem };diff --git a/skyvern-frontend/src/routes/history/RunHistory.runTags.test.tsx b/skyvern-frontend/src/routes/history/RunHistory.runTags.test.tsxindex 87c013a4e..b0a709776 100644--- a/skyvern-frontend/src/routes/history/RunHistory.runTags.test.tsx+++ b/skyvern-frontend/src/routes/history/RunHistory.runTags.test.tsx@@ -210,7 +210,11 @@ describe("RunHistory run tags", () => {).toContain("2 selected");fireEvent.contextMenu(screen.getByRole("row", { name: /tsk_1 Task Run/ }));- expect(screen.queryByRole("menu")).toBeNull();+ // Task rows get the shared row-actions menu too; during a bulk selection+ // it steers to the Actions bar instead of offering single-row actions.+ expect(screen.getByRole("menu").textContent).toContain(+ "Acts on this run only",+ );});it("hides selection when workflow tagging is disabled", () => {diff --git a/skyvern-frontend/src/routes/history/RunHistory.test.tsx b/skyvern-frontend/src/routes/history/RunHistory.test.tsxindex 7d7aefc82..eda8c5cdd 100644--- a/skyvern-frontend/src/routes/history/RunHistory.test.tsx+++ b/skyvern-frontend/src/routes/history/RunHistory.test.tsx@@ -306,7 +306,11 @@ describe("RunHistory inputs during filtering", () => {const runRow = screen.getByText("wr_123").closest("tr");expect(runRow).not.toBeNull();- fireEvent.click(within(runRow as HTMLElement).getByRole("button"));+ fireEvent.click(+ within(runRow as HTMLElement).getByRole("button", {+ name: "Show inputs",+ }),+ );expect(await screen.findByText("Run Inputs")).toBeTruthy();expect(screen.getByText("Paris")).toBeTruthy();diff --git a/skyvern-frontend/src/routes/history/RunHistory.tsx b/skyvern-frontend/src/routes/history/RunHistory.tsxindex 22474542f..5cabc6b13 100644--- a/skyvern-frontend/src/routes/history/RunHistory.tsx+++ b/skyvern-frontend/src/routes/history/RunHistory.tsx@@ -94,7 +94,7 @@ import {} from "@/components/SelectionCheckbox";import { useRowSelection } from "@/hooks/useRowSelection";import { RunBulkActionBar } from "@/routes/runs/RunBulkActionBar";-import { RunRowContextMenu } from "@/routes/runs/RunRowContextMenu";+import { RunRowActions } from "@/routes/runs/RunRowActions";const statusValues = new Set<string>(Object.values(Status));function isKnownStatus(value: string): value is Status {@@ -187,6 +187,19 @@ function getRunNavigationPath(run: TaskRunListItem): string {}}+// Rerun exists only for the task family served by /tasks/create/retry.+function getRerunPath(run: TaskRunListItem): string | null {+ switch (run.task_run_type) {+ case TaskRunType.TaskV1:+ case TaskRunType.OpenaiCua:+ case TaskRunType.AnthropicCua:+ case TaskRunType.UiTars:+ return `/tasks/create/retry/${run.run_id}`;+ default:+ return null;+ }+}+function RunHistory() {const onboarding = useOnboardingStateOptional();const isNewUser = onboarding?.isNewUser ?? false;@@ -445,7 +458,7 @@ function RunHistory() {(run.title ?? ""));- const mainRow = (+ const mainRow = (kebab: React.ReactNode) => (<TableRowclassName="group/row cursor-pointer select-none"data-state={isRowSelected ? "selected" : undefined}@@ -514,14 +527,19 @@ function RunHistory() {{executionTime ?? "-"}</TableCell><TableCell>- {isWorkflowRun ? (- <div className="flex justify-end">- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>+ <div className="flex justify-end gap-0.5">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span+ className="inline-flex"+ onClick={(event) => event.stopPropagation()}+ ><Buttonsize="icon"variant="ghost"+ disabled={!isWorkflowRun}+ aria-label={isExpanded ? "Hide inputs" : "Show inputs"}onClick={(event) => {event.stopPropagation();toggleParametersExpanded(run.run_id);@@ -533,36 +551,39 @@ function RunHistory() {><MixerHorizontalIcon className="h-4 w-4" /></Button>- </TooltipTrigger>- <TooltipContent>- {isExpanded ? "Hide Inputs" : "Show Inputs"}- </TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- ) : null}+ </span>+ </TooltipTrigger>+ <TooltipContent>+ {!isWorkflowRun+ ? "Inputs preview is only available for agent runs"+ : isExpanded+ ? "Hide Inputs"+ : "Show Inputs"}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ {kebab}+ </div></TableCell></TableRow>);return (<React.Fragment key={run.task_run_id}>- {taggable ? (- <RunRowContextMenu- workflowRunId={run.run_id}- runPath={navPath}- currentTags={runTags ?? []}- tagKeys={tagFilterKeys}- labelSuggestions={runTagSuggestions?.labels ?? []}- valueSuggestionsByKey={runTagSuggestions?.valuesByKey}- selectedCount={selectedRuns.length}- onNavigate={navigate}- >- {mainRow}- </RunRowContextMenu>- ) : (- mainRow- )}+ <RunRowActions+ runId={run.run_id}+ runPath={navPath}+ rerunPath={getRerunPath(run)}+ taggable={taggable}+ currentTags={runTags ?? []}+ tagKeys={tagFilterKeys}+ labelSuggestions={runTagSuggestions?.labels ?? []}+ valueSuggestionsByKey={runTagSuggestions?.valuesByKey}+ selectedCount={selectedRuns.length}+ onNavigate={navigate}+ >+ {mainRow}+ </RunRowActions>{isExpanded && run.workflow_permanent_id && (<TableRow key={`${run.run_id}-params`}><TableCelldiff --git a/skyvern-frontend/src/routes/runs/RunRowActions.tsx b/skyvern-frontend/src/routes/runs/RunRowActions.tsxnew file mode 100644index 000000000..1aae5828e--- /dev/null+++ b/skyvern-frontend/src/routes/runs/RunRowActions.tsx@@ -0,0 +1,112 @@+import {+ OpenInNewWindowIcon,+ ReloadIcon,+ TokensIcon,+} from "@radix-ui/react-icons";+import { type ReactElement, type ReactNode } from "react";++import {+ RowActionsContextMenu,+ RowActionsKebab,+ type RowActionItem,+} from "@/components/RowActions";+import { RunTagPickerCommand } from "@/routes/tasks/components/tagging/RunTagPickerCommand";+import type { Tag, TagKey } from "@/routes/workflows/types/tagTypes";++type Props = {+ runId: string;+ runPath: string;+ // Set for task-family rows that support /tasks/create/retry/{id}.+ rerunPath?: string | null;+ // Workflow-run rows with tagging enabled get the Tags submenu.+ taggable?: boolean;+ currentTags?: Array<Tag>;+ tagKeys?: Array<TagKey>;+ labelSuggestions?: Array<string>;+ valueSuggestionsByKey?: Map<string, Array<string>>;+ selectedCount?: number;+ onNavigate: (path: string) => void;+ // The row renderer; place the provided kebab last in the actions cell. It is+ // null while a selection is active (row menus yield to the bulk bar).+ children: (kebab: ReactNode) => ReactElement;+};++function RunRowActions({+ runId,+ runPath,+ rerunPath,+ taggable = false,+ currentTags = [],+ tagKeys = [],+ labelSuggestions = [],+ valueSuggestionsByKey,+ selectedCount = 0,+ onNavigate,+ children,+}: Props) {+ const isMultiSelect = selectedCount > 1;++ const items: Array<RowActionItem> = [];+ if (isMultiSelect) {+ items.push(+ {+ kind: "note",+ label: (+ <>+ Acts on this run only — use the Actions bar for all {selectedCount}.+ </>+ ),+ },+ { kind: "separator" },+ );+ } else {+ items.push({+ kind: "item",+ label: "Open run",+ icon: <OpenInNewWindowIcon className="mr-2 h-4 w-4" />,+ onSelect: () => onNavigate(runPath),+ });+ if (rerunPath) {+ items.push({+ kind: "item",+ label: "Rerun task",+ icon: <ReloadIcon className="mr-2 h-4 w-4" />,+ onSelect: () => onNavigate(rerunPath),+ });+ }+ if (taggable) {+ items.push({ kind: "separator" });+ }+ }+ if (taggable) {+ items.push({+ kind: "sub",+ label: "Tags",+ icon: <TokensIcon className="mr-2 h-4 w-4" />,+ contentClassName: "w-72 p-0",+ content: (+ <RunTagPickerCommand+ workflowRunId={runId}+ tagKeys={tagKeys}+ labelSuggestions={labelSuggestions}+ valueSuggestionsByKey={valueSuggestionsByKey}+ currentTags={currentTags}+ />+ ),+ });+ }++ // Row kebabs yield to the bulk Actions bar while any selection is active.+ const kebab =+ selectedCount > 0 ? null : (+ <RowActionsKebab items={items} ariaLabel={`Actions for run ${runId}`} />+ );++ return (+ <RowActionsContextMenu items={items}>+ {children(kebab)}+ </RowActionsContextMenu>+ );+}++export { RunRowActions };diff --git a/skyvern-frontend/src/routes/runs/RunRowContextMenu.tsx b/skyvern-frontend/src/routes/runs/RunRowContextMenu.tsxdeleted file mode 100644index 2ef513839..000000000--- a/skyvern-frontend/src/routes/runs/RunRowContextMenu.tsx+++ /dev/null@@ -1,101 +0,0 @@-import { OpenInNewWindowIcon, TokensIcon } from "@radix-ui/react-icons";-import {- Children,- cloneElement,- type ReactElement,- type ReactNode,- useState,-} from "react";--import {- ContextMenu,- ContextMenuContent,- ContextMenuItem,- ContextMenuLabel,- ContextMenuSeparator,- ContextMenuSub,- ContextMenuSubContent,- ContextMenuSubTrigger,- ContextMenuTrigger,-} from "@/components/ui/context-menu";-import { RunTagPickerCommand } from "@/routes/tasks/components/tagging/RunTagPickerCommand";-import type { Tag, TagKey } from "@/routes/workflows/types/tagTypes";-import { cn } from "@/util/utils";--type Props = {- workflowRunId: string;- runPath: string;- currentTags: Array<Tag>;- tagKeys: Array<TagKey>;- labelSuggestions: Array<string>;- valueSuggestionsByKey?: Map<string, Array<string>>;- selectedCount?: number;- onNavigate: (path: string) => void;- children: ReactNode;-};--function RunRowContextMenu({- workflowRunId,- runPath,- currentTags,- tagKeys,- labelSuggestions,- valueSuggestionsByKey,- selectedCount = 0,- onNavigate,- children,-}: Props) {- const child = Children.only(children) as ReactElement<{- className?: string;- "data-row-active"?: string;- }>;- const isMultiSelect = selectedCount > 1;- const [menuOpen, setMenuOpen] = useState(false);-- return (- <ContextMenu onOpenChange={setMenuOpen}>- <ContextMenuTrigger asChild>- {cloneElement(child, {- className: cn(child.props.className, "data-[row-active]:bg-muted/50"),- "data-row-active": menuOpen ? "" : undefined,- })}- </ContextMenuTrigger>- <ContextMenuContent className="w-56">- {isMultiSelect ? (- <>- <ContextMenuLabel className="text-xs font-normal text-muted-foreground">- Acts on this run only — use the Actions bar for all{" "}- {selectedCount}.- </ContextMenuLabel>- <ContextMenuSeparator />- </>- ) : (- <>- <ContextMenuItem onSelect={() => onNavigate(runPath)}>- <OpenInNewWindowIcon className="mr-2 h-4 w-4" />- Open run- </ContextMenuItem>- <ContextMenuSeparator />- </>- )}- <ContextMenuSub>- <ContextMenuSubTrigger>- <TokensIcon className="mr-2 h-4 w-4" />- Tags- </ContextMenuSubTrigger>- <ContextMenuSubContent className="w-72 p-0">- <RunTagPickerCommand- workflowRunId={workflowRunId}- tagKeys={tagKeys}- labelSuggestions={labelSuggestions}- valueSuggestionsByKey={valueSuggestionsByKey}- currentTags={currentTags}- />- </ContextMenuSubContent>- </ContextMenuSub>- </ContextMenuContent>- </ContextMenu>- );-}--export { RunRowContextMenu };diff --git a/skyvern-frontend/src/routes/runs/RunTagActions.test.tsx b/skyvern-frontend/src/routes/runs/RunTagActions.test.tsxindex 8554f0602..4eb4614e0 100644--- a/skyvern-frontend/src/routes/runs/RunTagActions.test.tsx+++ b/skyvern-frontend/src/routes/runs/RunTagActions.test.tsx@@ -15,7 +15,16 @@ vi.mock("@/components/ui/dropdown-menu", () => {return {DropdownMenu: Pass,DropdownMenuContent: Pass,+ DropdownMenuItem: ({+ children,+ onSelect,+ }: {+ children: ReactNode;+ onSelect?: () => void;+ }) => <button onClick={onSelect}>{children}</button>,+ DropdownMenuLabel: Pass,DropdownMenuPortal: Pass,+ DropdownMenuSeparator: () => null,DropdownMenuSub: Pass,DropdownMenuSubContent: Pass,DropdownMenuSubTrigger: Pass,@@ -63,7 +72,7 @@ vi.mock("@/routes/tasks/hooks/useRunTagMutations", () => ({vi.mock("@/components/ui/use-toast", () => ({ toast: vi.fn() }));import { RunBulkActionBar } from "./RunBulkActionBar";-import { RunRowContextMenu } from "./RunRowContextMenu";+import { RunRowActions } from "./RunRowActions";class MockResizeObserver {observe() {}@@ -148,21 +157,22 @@ describe("RunBulkActionBar", () => {});});-describe("RunRowContextMenu", () => {+describe("RunRowActions", () => {it("manages the clicked run and warns when a bulk selection is active", () => {const onNavigate = vi.fn();render(- <RunRowContextMenu- workflowRunId="wr_1"+ <RunRowActions+ runId="wr_1"runPath="/runs/wr_1"+ taggablecurrentTags={runTagsMap.wr_1}tagKeys={[]}labelSuggestions={[]}selectedCount={2}onNavigate={onNavigate}>- <div>Run row</div>- </RunRowContextMenu>,+ {() => <div>Run row</div>}+ </RunRowActions>,);expect(screen.getByText(/Acts on this run only/)).toBeTruthy();diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsxindex 238a54562..aa101a1ee 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx@@ -98,7 +98,7 @@ import {} from "@/components/SelectionCheckbox";import { useRowSelection } from "@/hooks/useRowSelection";import { RunBulkActionBar } from "@/routes/runs/RunBulkActionBar";-import { RunRowContextMenu } from "@/routes/runs/RunRowContextMenu";+import { RunRowActions } from "@/routes/runs/RunRowActions";import { WorkflowReliabilityPanel } from "./workflowRun/WorkflowReliabilityPanel";import { RunOutcomeRiskMarker } from "./workflowRun/RunOutcomeRiskMarker";import { useRunsHealSummaryBatchQuery } from "./hooks/useRunsHealSummaryBatchQuery";@@ -450,7 +450,7 @@ function WorkflowPage() {workflowRun.workflow_run_id,);- const mainRow = (+ const mainRow = (kebab: React.ReactNode) => (<TableRowonClick={(event) => {if (event.ctrlKey || event.metaKey) {@@ -529,6 +529,11 @@ function WorkflowPage() {<Buttonsize="icon"variant="ghost"+ aria-label={+ isExpanded+ ? "Hide inputs"+ : "Show inputs"+ }onClick={(event) => {event.stopPropagation();toggleParametersExpanded(@@ -549,6 +554,7 @@ function WorkflowPage() {</TooltipContent></Tooltip></TooltipProvider>+ {kebab}</div></TableCell></TableRow>@@ -556,24 +562,21 @@ function WorkflowPage() {return (<React.Fragment key={workflowRun.workflow_run_id}>- {taggingEnabled ? (- <RunRowContextMenu- workflowRunId={workflowRun.workflow_run_id}- runPath={runPath}- currentTags={runTags ?? []}- tagKeys={tagFilterKeys}- labelSuggestions={runTagSuggestions?.labels ?? []}- valueSuggestionsByKey={- runTagSuggestions?.valuesByKey- }- selectedCount={selectedRuns.length}- onNavigate={navigate}- >- {mainRow}- </RunRowContextMenu>- ) : (- mainRow- )}+ <RunRowActions+ runId={workflowRun.workflow_run_id}+ runPath={runPath}+ taggable={taggingEnabled}+ currentTags={runTags ?? []}+ tagKeys={tagFilterKeys}+ labelSuggestions={runTagSuggestions?.labels ?? []}+ valueSuggestionsByKey={+ runTagSuggestions?.valuesByKey+ }+ selectedCount={selectedRuns.length}+ onNavigate={navigate}+ >+ {mainRow}+ </RunRowActions>{/* Expanded parameters section */}{isExpanded && (<TableRowdiff --git a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsxindex b59ed7d2d..2106a0b5c 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx@@ -53,6 +53,7 @@ import { cn } from "@/util/utils";import {BookmarkFilledIcon,ChevronDownIcon,+ DotsHorizontalIcon,LightningBoltIcon,MixerHorizontalIcon,Pencil2Icon,@@ -82,7 +83,7 @@ import {} from "@/components/ui/dropdown-menu";import { NarrativeCard } from "./components/header/NarrativeCard";import { BulkActionBar } from "./components/BulkActionBar";-import { WorkflowRowContextMenu } from "./components/WorkflowRowContextMenu";+import { WorkflowRowActions } from "./components/WorkflowRowActions";import { FolderCard } from "./components/FolderCard";import { CreateFolderDialog } from "./components/CreateFolderDialog";import { CreateFromTemplateDialog } from "./components/CreateFromTemplateDialog";@@ -962,11 +963,19 @@ function WorkflowsFlat() {<Button size="icon" variant="ghost" disabled><Pencil2Icon className="h-4 w-4" /></Button>+ <Button+ size="icon"+ variant="ghost"+ disabled+ aria-label={`Actions for ${workflow.title}`}+ >+ <DotsHorizontalIcon className="h-4 w-4" />+ </Button></div></TableCell></TableRow>) : (- <WorkflowRowContextMenu+ <WorkflowRowActionsworkflow={workflow}tagKeys={tagKeys}labelSuggestions={labelSuggestions}@@ -982,134 +991,193 @@ function WorkflowsFlat() {replaceSelection(next);}}>- <TableRow- className="group/row cursor-pointer select-none"- data-state={isRowSelected ? "selected" : undefined}- >- {showCheckbox && (- <SelectionCheckboxCell- className="select-none"- index={selectableIndex}- checked={isRowSelected}- hasSelection={selected.size > 0}- onSelect={handleSelect}- ariaLabel={`Select ${workflow.title}`}- />- )}- <TableCell- onClick={(event) => {- handleRowClick(- event,- workflow.workflow_permanent_id,- );- }}+ {(kebab) => (+ <TableRow+ className="group/row cursor-pointer select-none"+ data-state={+ isRowSelected ? "selected" : undefined+ }>- <div- className="truncate font-mono text-xs text-muted-foreground"- title={workflow.workflow_permanent_id}- >- <HighlightText- text={workflow.workflow_permanent_id}- query={debouncedSearch}+ {showCheckbox && (+ <SelectionCheckboxCell+ className="select-none"+ index={selectableIndex}+ checked={isRowSelected}+ hasSelection={selected.size > 0}+ onSelect={handleSelect}+ ariaLabel={`Select ${workflow.title}`}/>- </div>- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(- event,- workflow.workflow_permanent_id,- );- }}- >- <div className="flex min-w-0 flex-col gap-1">- <div className="flex min-w-0 items-center gap-2">- <span- className="truncate"- title={workflow.title}- >- <HighlightText- text={workflow.title}- query={debouncedSearch}- />- </span>- {workflow.is_template && (- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <BookmarkFilledIcon className="h-3.5 w-3.5 shrink-0 text-blue-500" />- </TooltipTrigger>- <TooltipContent>- Template- </TooltipContent>- </Tooltip>- </TooltipProvider>- )}- <WorkflowReliabilityBadge- reliability={- workflowReliabilityMap[- workflow.workflow_permanent_id- ]- }+ )}+ <TableCell+ onClick={(event) => {+ handleRowClick(+ event,+ workflow.workflow_permanent_id,+ );+ }}+ >+ <div+ className="truncate font-mono text-xs text-muted-foreground"+ title={workflow.workflow_permanent_id}+ >+ <HighlightText+ text={workflow.workflow_permanent_id}+ query={debouncedSearch}/></div>- {taggingEnabled &&- workflowTags &&- workflowTags.length > 0 ? (- <TagChipList- tags={workflowTags}- descriptions={tagDescriptions}- colors={tagColors}- />- ) : null}- </div>- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(- event,- workflow.workflow_permanent_id,- );- }}- >- {workflow.folder_id ? (- <div className="flex min-w-0 items-center gap-1.5">- <FolderIcon className="h-3.5 w-3.5 shrink-0 text-blue-700 dark:text-blue-400" />- <span- className="truncate text-sm"- title={- foldersMap.get(workflow.folder_id)- ?.title || workflow.folder_id- }- >- <HighlightText- text={+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(+ event,+ workflow.workflow_permanent_id,+ );+ }}+ >+ <div className="flex min-w-0 flex-col gap-1">+ <div className="flex min-w-0 items-center gap-2">+ <span+ className="truncate"+ title={workflow.title}+ >+ <HighlightText+ text={workflow.title}+ query={debouncedSearch}+ />+ </span>+ {workflow.is_template && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <BookmarkFilledIcon className="h-3.5 w-3.5 shrink-0 text-blue-500" />+ </TooltipTrigger>+ <TooltipContent>+ Template+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ )}+ <WorkflowReliabilityBadge+ reliability={+ workflowReliabilityMap[+ workflow.workflow_permanent_id+ ]+ }+ />+ </div>+ {taggingEnabled &&+ workflowTags &&+ workflowTags.length > 0 ? (+ <TagChipList+ tags={workflowTags}+ descriptions={tagDescriptions}+ colors={tagColors}+ />+ ) : null}+ </div>+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(+ event,+ workflow.workflow_permanent_id,+ );+ }}+ >+ {workflow.folder_id ? (+ <div className="flex min-w-0 items-center gap-1.5">+ <FolderIcon className="h-3.5 w-3.5 shrink-0 text-blue-700 dark:text-blue-400" />+ <span+ className="truncate text-sm"+ title={foldersMap.get(workflow.folder_id)?.title || workflow.folder_id}- query={debouncedSearch}- />+ >+ <HighlightText+ text={+ foldersMap.get(workflow.folder_id)+ ?.title || workflow.folder_id+ }+ query={debouncedSearch}+ />+ </span>+ </div>+ ) : (+ <span className="text-muted-foreground">+ -</span>- </div>- ) : (- <span className="text-muted-foreground">-</span>- )}- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(- event,- workflow.workflow_permanent_id,- );- }}- className="text-muted-foreground"- title={basicTimeFormat(workflow.created_at)}- >- {compactLocalDateTime(workflow.created_at)}- </TableCell>- <TableCell>- <div className="flex justify-end gap-0.5">- {hasParameters && (+ )}+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(+ event,+ workflow.workflow_permanent_id,+ );+ }}+ className="text-muted-foreground"+ title={basicTimeFormat(workflow.created_at)}+ >+ {compactLocalDateTime(workflow.created_at)}+ </TableCell>+ <TableCell>+ <div className="flex justify-end gap-0.5">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="inline-flex">+ <Button+ size="icon"+ variant="ghost"+ className="text-muted-foreground hover:text-foreground"+ disabled={!hasParameters}+ aria-label={+ isExpanded+ ? "Hide parameters"+ : "Show parameters"+ }+ onClick={() =>+ toggleParametersExpanded(+ workflow.workflow_permanent_id,+ )+ }+ >+ <MixerHorizontalIcon className="h-4 w-4" />+ </Button>+ </span>+ </TooltipTrigger>+ <TooltipContent>+ {!hasParameters+ ? "No parameters defined"+ : isExpanded+ ? "Hide parameters"+ : "Show parameters"}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ size="icon"+ variant="ghost"+ className="text-cta hover:text-cta"+ onClick={(event) => {+ handleIconClick(+ event,+ `/agents/${workflow.workflow_permanent_id}/run`,+ );+ }}+ >+ <PlayIcon className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ Create New Run+ </TooltipContent>+ </Tooltip>+ </TooltipProvider><TooltipProvider><Tooltip><TooltipTrigger asChild>@@ -1117,74 +1185,30 @@ function WorkflowsFlat() {size="icon"variant="ghost"className="text-muted-foreground hover:text-foreground"- onClick={() =>- toggleParametersExpanded(- workflow.workflow_permanent_id,- )- }+ onClick={(event) => {+ handleIconClick(+ event,+ workflowEditorPath(+ workflow.workflow_permanent_id,+ studioEnabled,+ ),+ );+ }}>- <MixerHorizontalIcon className="h-4 w-4" />+ <Pencil2Icon className="h-4 w-4" /></Button></TooltipTrigger><TooltipContent>- {isExpanded- ? "Hide parameters"- : "Show parameters"}+ Open in Editor</TooltipContent></Tooltip></TooltipProvider>- )}- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- size="icon"- variant="ghost"- className="text-cta hover:text-cta"- onClick={(event) => {- handleIconClick(- event,- `/agents/${workflow.workflow_permanent_id}/run`,- );- }}- >- <PlayIcon className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- Create New Run- </TooltipContent>- </Tooltip>- </TooltipProvider>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- size="icon"- variant="ghost"- className="text-muted-foreground hover:text-foreground"- onClick={(event) => {- handleIconClick(- event,- workflowEditorPath(- workflow.workflow_permanent_id,- studioEnabled,- ),- );- }}- >- <Pencil2Icon className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>- Open in Editor- </TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- </TableCell>- </TableRow>- </WorkflowRowContextMenu>+ {kebab}+ </div>+ </TableCell>+ </TableRow>+ )}+ </WorkflowRowActions>)}{/* Expanded parameters section */}diff --git a/skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.delete.test.tsx b/skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.delete.test.tsxsimilarity index 95%rename from skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.delete.test.tsxrename to skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.delete.test.tsxindex 5b6e10c95..49bdc936c 100644--- a/skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.delete.test.tsx+++ b/skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.delete.test.tsx@@ -90,7 +90,7 @@ vi.mock("./tagging/TagPickerCommand", () => ({),}));-import { WorkflowRowContextMenu } from "./WorkflowRowContextMenu";+import { WorkflowRowActions } from "./WorkflowRowActions";import type { WorkflowApiResponse } from "../types/workflowTypes";function buildWorkflow(): WorkflowApiResponse {@@ -109,7 +109,7 @@ function renderMenu(props?: {}) {return render(<MemoryRouter>- <WorkflowRowContextMenu+ <WorkflowRowActionsworkflow={buildWorkflow()}tagKeys={[]}labelSuggestions={[]}@@ -119,8 +119,8 @@ function renderMenu(props?: {selectedCount={props?.selectedCount ?? 1}onDeleted={props?.onDeleted}>- <div>row</div>- </WorkflowRowContextMenu>+ {() => <div>row</div>}+ </WorkflowRowActions></MemoryRouter>,);}@@ -131,7 +131,7 @@ afterEach(() => {applyWorkflowTags.mockClear();});-describe("WorkflowRowContextMenu single-row delete", () => {+describe("WorkflowRowActions single-row delete", () => {it("notifies onDeleted with the workflow id after a successful delete", () => {const onDeleted = vi.fn();renderMenu({ selectedCount: 1, onDeleted });diff --git a/skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.tsx b/skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.tsxsimilarity index 51%rename from skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.tsxrename to skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.tsxindex 4a73ddb76..4b04698aa 100644--- a/skyvern-frontend/src/routes/workflows/components/WorkflowRowContextMenu.tsx+++ b/skyvern-frontend/src/routes/workflows/components/WorkflowRowActions.tsx@@ -11,18 +11,12 @@ import {} from "@radix-ui/react-icons";import { FolderIcon } from "@/components/icons/FolderIcon";import { GarbageIcon } from "@/components/icons/GarbageIcon";-import { Button } from "@/components/ui/button";import {- ContextMenu,- ContextMenuContent,- ContextMenuItem,- ContextMenuLabel,- ContextMenuSeparator,- ContextMenuSub,- ContextMenuSubContent,- ContextMenuSubTrigger,- ContextMenuTrigger,-} from "@/components/ui/context-menu";+ RowActionsContextMenu,+ RowActionsKebab,+ type RowActionItem,+} from "@/components/RowActions";+import { Button } from "@/components/ui/button";import {Dialog,DialogContent,@@ -30,10 +24,8 @@ import {DialogFooter,DialogHeader,DialogTitle,- DialogTrigger,} from "@/components/ui/dialog";import { toast } from "@/components/ui/use-toast";-import { cn } from "@/util/utils";import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { useUpdateWorkflowFolderMutation } from "../hooks/useFolderMutations";import { useApplyWorkflowTagsMutation } from "../hooks/useWorkflowTagMutations";@@ -58,10 +50,12 @@ type Props = {selectedCount?: number;// Defaults to shown; only an explicit false (cloud flag off) hides tagging.taggingEnabled?: boolean;- children: React.ReactNode;+ // The row renderer; place the provided kebab last in the actions cell. It is+ // null while a selection is active (row menus yield to the bulk bar).+ children: (kebab: React.ReactNode) => React.ReactElement;};-function WorkflowRowContextMenu({+function WorkflowRowActions({workflow,tagKeys,labelSuggestions,@@ -77,7 +71,6 @@ function WorkflowRowContextMenu({const updateFolderMutation = useUpdateWorkflowFolderMutation();const applyTagsMutation = useApplyWorkflowTagsMutation();const [deleteOpen, setDeleteOpen] = React.useState(false);- const [menuOpen, setMenuOpen] = React.useState(false);const [tagError, setTagError] = React.useState<string | null>(null);// Right-click still targets the single clicked row; until SKY-11504 lets it act// on the whole selection, steer multi-select to the bulk Actions bar.@@ -149,15 +142,129 @@ function WorkflowRowContextMenu({}}- // Keep the row highlighted while its context menu is open (the cursor leaves it).- // Children.only throws a clear error if the trigger ever wraps more than one node.- const child = React.Children.only(children) as React.ReactElement<{- className?: string;- }>;- const rowProps = {- className: cn(child.props.className, "data-[row-active]:bg-muted/50"),- "data-row-active": menuOpen ? "" : undefined,- };+ const items: Array<RowActionItem> = [];+ if (isMultiSelect) {+ items.push(+ {+ kind: "note",+ label: (+ <>+ Acts on this agent only — use the Actions bar for all{" "}+ {selectedCount}.+ </>+ ),+ },+ { kind: "separator" },+ );+ }+ if (selectedCount <= 1) {+ items.push(+ {+ kind: "item",+ label: "Open in editor",+ icon: <Pencil2Icon className="mr-2 h-4 w-4" />,+ onSelect: () =>+ onNavigate(+ workflowEditorPath(workflow.workflow_permanent_id, studioEnabled),+ ),+ },+ {+ kind: "item",+ label: "Run",+ icon: <PlayIcon className="mr-2 h-4 w-4" />,+ onSelect: () =>+ onNavigate(`/agents/${workflow.workflow_permanent_id}/run`),+ },+ { kind: "separator" },+ );+ }+ if (taggingEnabled) {+ items.push({+ kind: "sub",+ label: "Tags",+ icon: <TokensIcon className="mr-2 h-4 w-4" />,+ contentClassName: "w-72 p-0",+ onOpenChange: (open) => {+ if (!open) {+ setTagError(null);+ }+ },+ content: (+ <TagPickerCommand+ tagKeys={tagKeys}+ labelSuggestions={labelSuggestions}+ valueSuggestionsByKey={valueSuggestionsByKey}+ currentTags={currentTags}+ error={tagError}+ onErrorChange={setTagError}+ disabled={applyTagsMutation.isPending}+ onApply={applyTag}+ onRemove={removeTag}+ />+ ),+ });+ }+ items.push(+ {+ kind: "sub",+ label: "Move to folder",+ icon: <FolderIcon className="mr-2 h-4 w-4" />,+ contentClassName: "w-72 p-0",+ content: (+ <FolderPickerCommand+ currentFolderId={workflow.folder_id ?? null}+ onSelect={(folderId) => void moveToFolder(folderId)}+ />+ ),+ },+ { kind: "separator" },+ {+ kind: "item",+ label: "Duplicate Agent",+ icon: <CopyIcon className="mr-2 h-4 w-4" />,+ onSelect: () => clone(),+ disabled: isMultiSelect,+ },+ {+ kind: "item",+ label: workflow.is_template ? "Remove from template" : "Save as template",+ icon: workflow.is_template ? (+ <BookmarkFilledIcon className="mr-2 h-4 w-4" />+ ) : (+ <BookmarkIcon className="mr-2 h-4 w-4" />+ ),+ onSelect: () => toggleTemplate(),+ disabled: isMultiSelect || isTogglingTemplate,+ },+ {+ kind: "sub",+ label: "Export",+ icon: <DownloadIcon className="mr-2 h-4 w-4" />,+ disabled: isMultiSelect,+ items: [+ { label: "YAML", onSelect: () => exportAs("yaml") },+ { label: "JSON", onSelect: () => exportAs("json") },+ ],+ },+ { kind: "separator" },+ {+ kind: "item",+ label: "Delete",+ icon: <GarbageIcon className="mr-2 h-4 w-4 text-destructive" />,+ destructive: true,+ disabled: isMultiSelect,+ dialogTrigger: true,+ },+ );++ // Row kebabs yield to the bulk Actions bar while any selection is active.+ const kebab =+ selectedCount > 0 ? null : (+ <RowActionsKebab+ items={items}+ ariaLabel={`Actions for ${workflow.title}`}+ />+ );return (<Dialog@@ -168,134 +275,16 @@ function WorkflowRowContextMenu({}}}>- <ContextMenu+ <RowActionsContextMenu+ items={items}onOpenChange={(open) => {- setMenuOpen(open);if (!open) {setTagError(null);}}}>- <ContextMenuTrigger asChild>- {React.cloneElement(child, rowProps)}- </ContextMenuTrigger>- <ContextMenuContent className="w-56">- {isMultiSelect && (- <>- <ContextMenuLabel className="text-xs font-normal text-muted-foreground">- Acts on this agent only — use the Actions bar for all{" "}- {selectedCount}.- </ContextMenuLabel>- <ContextMenuSeparator />- </>- )}- {selectedCount <= 1 && (- <>- <ContextMenuItem- onSelect={() =>- onNavigate(- workflowEditorPath(- workflow.workflow_permanent_id,- studioEnabled,- ),- )- }- >- <Pencil2Icon className="mr-2 h-4 w-4" />- Open in editor- </ContextMenuItem>- <ContextMenuItem- onSelect={() =>- onNavigate(`/agents/${workflow.workflow_permanent_id}/run`)- }- >- <PlayIcon className="mr-2 h-4 w-4" />- Run- </ContextMenuItem>- <ContextMenuSeparator />- </>- )}- {taggingEnabled ? (- <ContextMenuSub- onOpenChange={(open) => {- if (!open) {- setTagError(null);- }- }}- >- <ContextMenuSubTrigger>- <TokensIcon className="mr-2 h-4 w-4" />- Tags- </ContextMenuSubTrigger>- <ContextMenuSubContent className="w-72 p-0">- <TagPickerCommand- tagKeys={tagKeys}- labelSuggestions={labelSuggestions}- valueSuggestionsByKey={valueSuggestionsByKey}- currentTags={currentTags}- error={tagError}- onErrorChange={setTagError}- disabled={applyTagsMutation.isPending}- onApply={applyTag}- onRemove={removeTag}- />- </ContextMenuSubContent>- </ContextMenuSub>- ) : null}- <ContextMenuSub>- <ContextMenuSubTrigger>- <FolderIcon className="mr-2 h-4 w-4" />- Move to folder- </ContextMenuSubTrigger>- <ContextMenuSubContent className="w-72 p-0">- <FolderPickerCommand- currentFolderId={workflow.folder_id ?? null}- onSelect={(folderId) => void moveToFolder(folderId)}- />- </ContextMenuSubContent>- </ContextMenuSub>- <ContextMenuSeparator />- <ContextMenuItem onSelect={() => clone()} disabled={isMultiSelect}>- <CopyIcon className="mr-2 h-4 w-4" />- Duplicate Agent- </ContextMenuItem>- <ContextMenuItem- onSelect={() => toggleTemplate()}- disabled={isMultiSelect || isTogglingTemplate}- >- {workflow.is_template ? (- <BookmarkFilledIcon className="mr-2 h-4 w-4" />- ) : (- <BookmarkIcon className="mr-2 h-4 w-4" />- )}- {workflow.is_template ? "Remove from template" : "Save as template"}- </ContextMenuItem>- <ContextMenuSub>- <ContextMenuSubTrigger disabled={isMultiSelect}>- <DownloadIcon className="mr-2 h-4 w-4" />- Export- </ContextMenuSubTrigger>- <ContextMenuSubContent>- <ContextMenuItem onSelect={() => exportAs("yaml")}>- YAML- </ContextMenuItem>- <ContextMenuItem onSelect={() => exportAs("json")}>- JSON- </ContextMenuItem>- </ContextMenuSubContent>- </ContextMenuSub>- <ContextMenuSeparator />- <DialogTrigger asChild>- <ContextMenuItem- className="text-destructive focus:text-destructive"- disabled={isMultiSelect}- >- <GarbageIcon className="mr-2 h-4 w-4 text-destructive" />- Delete- </ContextMenuItem>- </DialogTrigger>- </ContextMenuContent>- </ContextMenu>+ {children(kebab)}+ </RowActionsContextMenu><DialogContent onCloseAutoFocus={(e) => e.preventDefault()}><DialogHeader><DialogTitle>Are you sure?</DialogTitle>@@ -334,4 +323,4 @@ function WorkflowRowContextMenu({);}-export { WorkflowRowContextMenu };+export { WorkflowRowActions };diff --git a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tagging.test.tsx b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tagging.test.tsxindex a4a73ec3a..4a01870cd 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tagging.test.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tagging.test.tsx@@ -19,8 +19,12 @@ import {vi.mock("../tagging/TagChipList", () => ({TagChipList: () => <span data-testid="tag-chip-list" />,}));-vi.mock("../WorkflowRowContextMenu", () => ({- WorkflowRowContextMenu: ({ children }: { children: ReactNode }) => children,+vi.mock("../WorkflowRowActions", () => ({+ WorkflowRowActions: ({+ children,+ }: {+ children: (kebab: ReactNode) => ReactNode;+ }) => children(null),}));vi.mock("@/hooks/useWorkflowStudioEnabled", () => ({useWorkflowStudioEnabled: () => false,diff --git a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsxindex d078dbe33..86b65f7d0 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx@@ -1,6 +1,7 @@import React from "react";import {BookmarkFilledIcon,+ DotsHorizontalIcon,MixerHorizontalIcon,Pencil2Icon,PlayIcon,@@ -26,7 +27,7 @@ import { HighlightText } from "../HighlightText";import { ParameterDisplayInline } from "../ParameterDisplayInline";import { TagChipList } from "../tagging/TagChipList";import { WorkflowReliabilityBadge } from "../../WorkflowReliabilityBadge";-import { WorkflowRowContextMenu } from "../WorkflowRowContextMenu";+import { WorkflowRowActions } from "../WorkflowRowActions";import { useWorkflowsListContext } from "./WorkflowsListContext";import { useNavigate } from "react-router-dom";@@ -123,6 +124,14 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {<Button size="icon" variant="ghost" disabled><Pencil2Icon className="h-4 w-4" /></Button>+ <Button+ size="icon"+ variant="ghost"+ disabled+ aria-label={`Actions for ${workflow.title}`}+ >+ <DotsHorizontalIcon className="h-4 w-4" />+ </Button></div></TableCell></TableRow>@@ -131,7 +140,7 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {return (<React.Fragment>- <WorkflowRowContextMenu+ <WorkflowRowActionsworkflow={workflow}tagKeys={tagKeys}labelSuggestions={labelSuggestions}@@ -142,114 +151,165 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {onNavigate={(path) => navigate(path)}onDeleted={onRowDeleted}>- <TableRow- className="group/row cursor-pointer select-none"- data-state={isRowSelected ? "selected" : undefined}- >- {showCheckbox && (- <SelectionCheckboxCell- className="select-none"- index={selectableIndex}- checked={isRowSelected}- hasSelection={selectedCount > 0}- onSelect={handleSelect}- ariaLabel={`Select ${workflow.title}`}- />- )}- <TableCell- style={firstCellStyle}- onClick={(event) => {- handleRowClick(event, workflow.workflow_permanent_id);- }}+ {(kebab) => (+ <TableRow+ className="group/row cursor-pointer select-none"+ data-state={isRowSelected ? "selected" : undefined}>- <div- className="truncate font-mono text-xs text-muted-foreground"- title={workflow.workflow_permanent_id}- >- <HighlightText- text={workflow.workflow_permanent_id}- query={debouncedSearch}+ {showCheckbox && (+ <SelectionCheckboxCell+ className="select-none"+ index={selectableIndex}+ checked={isRowSelected}+ hasSelection={selectedCount > 0}+ onSelect={handleSelect}+ ariaLabel={`Select ${workflow.title}`}/>- </div>- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(event, workflow.workflow_permanent_id);- }}- >- <div className="flex min-w-0 flex-col gap-1">- <div className="flex min-w-0 items-center gap-2">- <span className="truncate" title={workflow.title}>- <HighlightText- text={workflow.title}- query={debouncedSearch}- />- </span>- {workflow.is_template && (- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <BookmarkFilledIcon className="h-3.5 w-3.5 shrink-0 text-blue-500" />- </TooltipTrigger>- <TooltipContent>Template</TooltipContent>- </Tooltip>- </TooltipProvider>- )}- <WorkflowReliabilityBadge- reliability={- workflowReliabilityMap[workflow.workflow_permanent_id]- }+ )}+ <TableCell+ style={firstCellStyle}+ onClick={(event) => {+ handleRowClick(event, workflow.workflow_permanent_id);+ }}+ >+ <div+ className="truncate font-mono text-xs text-muted-foreground"+ title={workflow.workflow_permanent_id}+ >+ <HighlightText+ text={workflow.workflow_permanent_id}+ query={debouncedSearch}/></div>- {taggingEnabled && workflowTags && workflowTags.length > 0 ? (- <TagChipList- tags={workflowTags}- descriptions={tagDescriptions}- colors={tagColors}- />- ) : null}- </div>- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(event, workflow.workflow_permanent_id);- }}- >- {workflow.folder_id ? (- <div className="flex min-w-0 items-center gap-1.5">- <FolderIcon className="h-3.5 w-3.5 shrink-0 text-blue-700 dark:text-blue-400" />- <span- className="truncate text-sm"- title={- foldersMap.get(workflow.folder_id)?.title ||- workflow.folder_id- }- >- <HighlightText- text={- foldersMap.get(workflow.folder_id)?.title ||- workflow.folder_id+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(event, workflow.workflow_permanent_id);+ }}+ >+ <div className="flex min-w-0 flex-col gap-1">+ <div className="flex min-w-0 items-center gap-2">+ <span className="truncate" title={workflow.title}>+ <HighlightText+ text={workflow.title}+ query={debouncedSearch}+ />+ </span>+ {workflow.is_template && (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <BookmarkFilledIcon className="h-3.5 w-3.5 shrink-0 text-blue-500" />+ </TooltipTrigger>+ <TooltipContent>Template</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ )}+ <WorkflowReliabilityBadge+ reliability={+ workflowReliabilityMap[workflow.workflow_permanent_id]}- query={debouncedSearch}/>- </span>+ </div>+ {taggingEnabled && workflowTags && workflowTags.length > 0 ? (+ <TagChipList+ tags={workflowTags}+ descriptions={tagDescriptions}+ colors={tagColors}+ />+ ) : null}</div>- ) : (- <span className="text-muted-foreground">-</span>- )}- </TableCell>- <TableCell- onClick={(event) => {- handleRowClick(event, workflow.workflow_permanent_id);- }}- className="text-muted-foreground"- title={basicTimeFormat(workflow.created_at)}- >- {compactLocalDateTime(workflow.created_at)}- </TableCell>- <TableCell>- <div className="flex justify-end gap-0.5">- {hasParameters && (+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(event, workflow.workflow_permanent_id);+ }}+ >+ {workflow.folder_id ? (+ <div className="flex min-w-0 items-center gap-1.5">+ <FolderIcon className="h-3.5 w-3.5 shrink-0 text-blue-700 dark:text-blue-400" />+ <span+ className="truncate text-sm"+ title={+ foldersMap.get(workflow.folder_id)?.title ||+ workflow.folder_id+ }+ >+ <HighlightText+ text={+ foldersMap.get(workflow.folder_id)?.title ||+ workflow.folder_id+ }+ query={debouncedSearch}+ />+ </span>+ </div>+ ) : (+ <span className="text-muted-foreground">-</span>+ )}+ </TableCell>+ <TableCell+ onClick={(event) => {+ handleRowClick(event, workflow.workflow_permanent_id);+ }}+ className="text-muted-foreground"+ title={basicTimeFormat(workflow.created_at)}+ >+ {compactLocalDateTime(workflow.created_at)}+ </TableCell>+ <TableCell>+ <div className="flex justify-end gap-0.5">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="inline-flex">+ <Button+ size="icon"+ variant="ghost"+ className="text-muted-foreground hover:text-foreground"+ disabled={!hasParameters}+ aria-label={+ isExpanded ? "Hide parameters" : "Show parameters"+ }+ onClick={() =>+ toggleParametersExpanded(+ workflow.workflow_permanent_id,+ )+ }+ >+ <MixerHorizontalIcon className="h-4 w-4" />+ </Button>+ </span>+ </TooltipTrigger>+ <TooltipContent>+ {!hasParameters+ ? "No parameters defined"+ : isExpanded+ ? "Hide parameters"+ : "Show parameters"}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ size="icon"+ variant="ghost"+ className="text-cta hover:text-cta"+ onClick={(event) => {+ handleIconClick(+ event,+ `/agents/${workflow.workflow_permanent_id}/run`,+ );+ }}+ >+ <PlayIcon className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>Create New Run</TooltipContent>+ </Tooltip>+ </TooltipProvider><TooltipProvider><Tooltip><TooltipTrigger asChild>@@ -257,68 +317,28 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {size="icon"variant="ghost"className="text-muted-foreground hover:text-foreground"- onClick={() =>- toggleParametersExpanded(- workflow.workflow_permanent_id,- )- }+ onClick={(event) => {+ handleIconClick(+ event,+ workflowEditorPath(+ workflow.workflow_permanent_id,+ studioEnabled,+ ),+ );+ }}>- <MixerHorizontalIcon className="h-4 w-4" />+ <Pencil2Icon className="h-4 w-4" /></Button></TooltipTrigger>- <TooltipContent>- {isExpanded ? "Hide parameters" : "Show parameters"}- </TooltipContent>+ <TooltipContent>Open in Editor</TooltipContent></Tooltip></TooltipProvider>- )}- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- size="icon"- variant="ghost"- className="text-cta hover:text-cta"- onClick={(event) => {- handleIconClick(- event,- `/agents/${workflow.workflow_permanent_id}/run`,- );- }}- >- <PlayIcon className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>Create New Run</TooltipContent>- </Tooltip>- </TooltipProvider>- <TooltipProvider>- <Tooltip>- <TooltipTrigger asChild>- <Button- size="icon"- variant="ghost"- className="text-muted-foreground hover:text-foreground"- onClick={(event) => {- handleIconClick(- event,- workflowEditorPath(- workflow.workflow_permanent_id,- studioEnabled,- ),- );- }}- >- <Pencil2Icon className="h-4 w-4" />- </Button>- </TooltipTrigger>- <TooltipContent>Open in Editor</TooltipContent>- </Tooltip>- </TooltipProvider>- </div>- </TableCell>- </TableRow>- </WorkflowRowContextMenu>+ {kebab}+ </div>+ </TableCell>+ </TableRow>+ )}+ </WorkflowRowActions>{isExpanded && hasParameters && (<TableRow>diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex 1cd992407..d696e1eca 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -142,7 +142,11 @@ from skyvern.services import run_service, service_utilsfrom skyvern.services.action_service import get_action_historyfrom skyvern.services.error_detection_service import detect_user_defined_errors_for_taskfrom skyvern.services.otp_service import poll_otp_value, resolve_otp_value-from skyvern.services.webhook_delivery import WEBHOOK_DELIVERY_MAX_ATTEMPTS, deliver_webhook_with_retries+from skyvern.services.webhook_delivery import (+ WEBHOOK_DELIVERY_MAX_ATTEMPTS,+ deliver_webhook_with_retries,+ describe_delivery_error,+)from skyvern.utils.image_resizer import Resolutionfrom skyvern.utils.prompt_engine import (PROMPT_HARD_CEILING_TOKENS,@@ -4995,15 +4999,37 @@ class ForgeAgent:headers=signed_data.headers,)- resp = await deliver_webhook_with_retries(- url=task.webhook_callback_url,- payload=signed_data.signed_payload,- headers=signed_data.headers,- timeout_seconds=30.0,- organization_id=task.organization_id,- run_id=task.task_id,- max_attempts=WEBHOOK_DELIVERY_MAX_ATTEMPTS if enable_retries else 1,- )+ try:+ resp = await deliver_webhook_with_retries(+ url=task.webhook_callback_url,+ payload=signed_data.signed_payload,+ headers=signed_data.headers,+ timeout_seconds=30.0,+ organization_id=task.organization_id,+ run_id=task.task_id,+ max_attempts=WEBHOOK_DELIVERY_MAX_ATTEMPTS if enable_retries else 1,+ )+ except Exception as delivery_error:+ LOG.warning(+ "Task webhook delivery failed after attempting delivery",+ task_id=task.task_id,+ organization_id=task.organization_id,+ error=describe_delivery_error(delivery_error),+ exc_info=True,+ )+ try:+ await app.DATABASE.tasks.update_task(+ task_id=task.task_id,+ organization_id=task.organization_id,+ webhook_failure_reason=f"Webhook delivery failed before receiving a response: {describe_delivery_error(delivery_error)}",+ )+ except Exception:+ LOG.warning(+ "Failed to record task webhook delivery error",+ task_id=task.task_id,+ exc_info=True,+ )+ raiseif resp.status_code >= 200 and resp.status_code < 300:LOG.info("Webhook sent successfully",@@ -5194,17 +5220,23 @@ class ForgeAgent:data=video_artifact.video_data,)continue- # No pre-registered artifact row: a recording attached at browser teardown- # (remote-CDP path) needs a RECORDING artifact created from the on-disk file.- # Upload by path so the bytes stream straight from disk to storage.+ # A teardown-attached recording has no pre-registered artifact row.+ # Prefer collected video bytes; use the on-disk path only when no bytes were returned.video_path = video_artifact.video_path- if not video_path or not os.path.exists(video_path):+ if video_artifact.video_data:+ video_artifact.video_artifact_id = await app.ARTIFACT_MANAGER.create_artifact(+ step=last_step,+ artifact_type=ArtifactType.RECORDING,+ data=video_artifact.video_data,+ )+ elif video_path and os.path.exists(video_path):+ video_artifact.video_artifact_id = await app.ARTIFACT_MANAGER.create_artifact(+ step=last_step,+ artifact_type=ArtifactType.RECORDING,+ path=video_path,+ )+ else:continue- video_artifact.video_artifact_id = await app.ARTIFACT_MANAGER.create_artifact(- step=last_step,- artifact_type=ArtifactType.RECORDING,- path=video_path,- )_ctx = skyvern_context.current()_use_bundling = _ctx.use_artifact_bundling if _ctx else Falsediff --git a/skyvern/forge/sdk/db/repositories/tasks.py b/skyvern/forge/sdk/db/repositories/tasks.pyindex e17b9bd96..8a6ab4c4c 100644--- a/skyvern/forge/sdk/db/repositories/tasks.py+++ b/skyvern/forge/sdk/db/repositories/tasks.py@@ -89,6 +89,7 @@ class TasksRepository(BaseRepository):async with self.Session() as session:new_task = TaskModel(status=status,+ started_at=naive_utc_now() if str(status) == TaskStatus.running.value else None,task_type=task_type,url=url,title=title,diff --git a/skyvern/forge/sdk/db/repositories/workflow_parameters.py b/skyvern/forge/sdk/db/repositories/workflow_parameters.pyindex ab5d5111a..09b43183b 100644--- a/skyvern/forge/sdk/db/repositories/workflow_parameters.py+++ b/skyvern/forge/sdk/db/repositories/workflow_parameters.py@@ -984,6 +984,10 @@ class WorkflowParametersRepository(BaseRepository):"confidence_float": action.confidence_float,"created_by": action.created_by,}+ if action.created_at is not None:+ values["created_at"] = action.created_at+ if action.modified_at is not None:+ values["modified_at"] = action.modified_atasync with self.Session() as session:stmt = pg_insert(ActionModel).values(**values)stmt = stmt.on_conflict_do_update(@@ -991,7 +995,7 @@ class WorkflowParametersRepository(BaseRepository):set_={"screenshot_artifact_id": stmt.excluded.screenshot_artifact_id,"action_json": stmt.excluded.action_json,- "modified_at": datetime.now(timezone.utc),+ "modified_at": stmt.excluded.modified_at,},)await session.execute(stmt)diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.pyindex 4f90d03de..a4355854e 100644--- a/skyvern/forge/sdk/routes/agent_protocol.py+++ b/skyvern/forge/sdk/routes/agent_protocol.py@@ -1763,7 +1763,7 @@ async def require_workflow_tagging("/workflows/{workflow_permanent_id}/tags",response_model=TagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "apply_workflow_tags"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "apply_workflow_tags"},description="Atomically apply tag changes to a workflow. Sets and deletes happen in one transaction; ""same-key collisions resolve set-wins.",summary="Apply agent tags",@@ -1819,7 +1819,7 @@ async def apply_workflow_tags("/workflows/{workflow_permanent_id}/tags/{key}",response_model=TagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "delete_workflow_tag"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "delete_workflow_tag"},description="Soft-delete a single tag from a workflow. Writes a DELETE event row.",summary="Delete agent tag",responses={@@ -1865,7 +1865,7 @@ async def delete_workflow_tag("/workflows/{workflow_permanent_id}/tags",response_model=TagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "get_workflow_tags"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "get_workflow_tags"},description="Get the current tag state for a workflow.",summary="Get agent tags",responses={@@ -1912,7 +1912,7 @@ async def _build_tags_response(workflow_permanent_id: str, organization_id: str)"/workflows/{workflow_permanent_id}/tags/history",response_model=TagHistoryResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "get_workflow_tag_history"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "get_workflow_tag_history"},description="Chronological tag-event log for a workflow (newest first). Includes SET and DELETE events.",summary="Get agent tag history",responses={@@ -1959,7 +1959,7 @@ async def get_workflow_tag_history("/runs/{workflow_run_id}/tags",response_model=RunTagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "apply_run_tags"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "apply_run_tags"},description="Atomically apply tag changes to a workflow run. Sets and deletes happen in one transaction; ""same-key collisions resolve set-wins.",summary="Apply run tags",@@ -2011,7 +2011,7 @@ async def apply_run_tags("/runs/{workflow_run_id}/tags/{key}",response_model=RunTagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "delete_run_tag"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "delete_run_tag"},description="Soft-delete a single grouped tag from a workflow run. Writes a DELETE event row.",summary="Delete run tag",responses={@@ -2052,7 +2052,7 @@ async def delete_run_tag("/runs/{workflow_run_id}/tags",response_model=RunTagsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "get_run_tags"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "get_run_tags"},description="Get the current tag state for a workflow run.",summary="Get run tags",responses={@@ -2096,7 +2096,7 @@ async def _build_run_tags_response(workflow_run_id: str, organization_id: str) -"/runs/{workflow_run_id}/tags/history",response_model=RunTagHistoryResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "get_run_tag_history"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "get_run_tag_history"},description="Chronological tag-event log for a workflow run (newest first). Includes SET and DELETE events.",summary="Get run tag history",responses={@@ -2138,7 +2138,7 @@ async def get_run_tag_history("/tag-keys",response_model=list[TagKey],tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "list_tag_keys"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "list_tag_keys"},description="List all tag keys registered for the organization with their descriptions.",summary="List tag keys",responses={200: {"description": "Successfully retrieved tag keys"}},@@ -2160,7 +2160,7 @@ async def list_tag_keys("/tag-keys/{key}",response_model=TagKey,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "update_tag_key"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "update_tag_key"},description="Update the description for a tag key.",summary="Update tag key",responses={@@ -2197,7 +2197,7 @@ async def update_tag_key("/tag-keys/{key}",response_model=TagKeyDeleteResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "delete_tag_key"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "delete_tag_key"},description="Delete a tag key from the organization registry and remove that tag from every workflow that ""currently has it (cascade). Returns how many workflows the tag was removed from.",summary="Delete tag key",@@ -2237,7 +2237,7 @@ async def delete_tag_key("/tag-values",response_model=list[TagValue],tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "list_tag_values"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "list_tag_values"},description="List the palette color and current workflow usage count for each grouped tag (key, value) ""for the organization. The frontend joins these onto tags by (key, value); workflow_count is the number ""of non-deleted workflows carrying the label and powers the per-label usage and delete blast-radius warnings.",@@ -2270,7 +2270,7 @@ async def list_tag_values("/tag-values",response_model=TagValue,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "create_tag_value"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "create_tag_value"},description="Register a grouped tag (key, value) with a palette color before any workflow uses it. ""The label shows a zero workflow count until applied to a workflow.",summary="Create tag value",@@ -2305,7 +2305,7 @@ async def create_tag_value("/tag-values/{key}",response_model=TagValue,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "update_tag_value"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "update_tag_value"},description="Recolor a grouped tag (key, value). The value is supplied in the body so values ""containing '/' stay addressable. The new color must be a palette name.",summary="Update tag value color",@@ -2347,7 +2347,7 @@ async def update_tag_value("/tag-values/{key}/rename",response_model=TagValueRenameResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "rename_tag_value"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "rename_tag_value"},description="Rename a grouped tag (key, value) to (key, new_value). The cascade re-tags every workflow ""carrying the old label; the new label inherits the old color. Both values ride in the body so values ""containing '/' stay addressable. Rejects with 409 when the new value already exists for the key.",@@ -2398,7 +2398,7 @@ async def rename_tag_value("/tag-values/{key}",response_model=TagValueDeleteResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "delete_tag_value"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "delete_tag_value"},description="Soft-delete a grouped tag (key, value) and remove that label from every workflow carrying it ""(cascade). The value rides in the body so values containing '/' stay addressable. Returns how many ""workflows the label was removed from.",@@ -2686,7 +2686,7 @@ async def batch_get_run_tags_post("/run-tag-suggestions",response_model=RunTagSuggestionsResponse,tags=["Tags"],- openapi_extra={"x-fern-sdk-method-name": "get_run_tag_suggestions"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "get_run_tag_suggestions"},description="List distinct (key, value) pairs ever set on a run for the organization, sourced from the ""run-tag event log rather than the tag-key/tag-value registry. Surfaces reserved 'skyvern.*' system keys ""(which are never registered) so pickers can offer them alongside user-defined tags.",diff --git a/skyvern/forge/sdk/routes/custom_llms.py b/skyvern/forge/sdk/routes/custom_llms.pyindex 88ad3fe6a..3c9cae191 100644--- a/skyvern/forge/sdk/routes/custom_llms.py+++ b/skyvern/forge/sdk/routes/custom_llms.py@@ -75,7 +75,7 @@ def _config_with_preserved_api_key(config: CustomLLMConfig, existing_custom_llm:summary="List Custom LLMs",description="List the custom LLM configurations available to the current organization.",tags=["Custom LLMs"],- openapi_extra={"x-fern-sdk-method-name": "list_custom_llms"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "list_custom_llms"},)@base_router.get("/custom-llms/",@@ -111,7 +111,7 @@ async def list_custom_llms(summary="Create Custom LLM",description="Create a custom LLM configuration for the current organization.",tags=["Custom LLMs"],- openapi_extra={"x-fern-sdk-method-name": "create_custom_llm"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "create_custom_llm"},)@base_router.post("/custom-llms/",@@ -139,7 +139,7 @@ async def create_custom_llm(summary="Update Custom LLM",description="Update a custom LLM configuration for the current organization.",tags=["Custom LLMs"],- openapi_extra={"x-fern-sdk-method-name": "update_custom_llm"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "update_custom_llm"},)@base_router.put("/custom-llms/{custom_llm_id}/",@@ -175,7 +175,7 @@ async def update_custom_llm(summary="Delete Custom LLM",description="Delete a custom LLM configuration for the current organization.",tags=["Custom LLMs"],- openapi_extra={"x-fern-sdk-method-name": "delete_custom_llm"},+ openapi_extra={"x-hidden": True, "x-fern-sdk-method-name": "delete_custom_llm"},)@base_router.delete("/custom-llms/{custom_llm_id}/",diff --git a/skyvern/forge/sdk/routes/scripts.py b/skyvern/forge/sdk/routes/scripts.pyindex d076a943c..3ecefeda6 100644--- a/skyvern/forge/sdk/routes/scripts.py+++ b/skyvern/forge/sdk/routes/scripts.py@@ -230,6 +230,7 @@ async def get_script_blocks_response(description="Create a new script with optional files and metadata",tags=["Scripts"],openapi_extra={+ "x-hidden": True,"x-fern-sdk-method-name": "create_script",},)@@ -276,6 +277,7 @@ async def deploy_cached_script(description="Retrieves a specific script by its ID",tags=["Scripts"],openapi_extra={+ "x-hidden": True,"x-fern-sdk-method-name": "get_script",},)@@ -499,6 +501,7 @@ async def get_script_version_detail(description="Retrieves a paginated list of scripts for the current organization",tags=["Scripts"],openapi_extra={+ "x-hidden": True,"x-fern-sdk-method-name": "get_scripts",},)@@ -546,6 +549,7 @@ async def get_scripts(description="Deploy a script with updated files, creating a new version",tags=["Scripts"],openapi_extra={+ "x-hidden": True,"x-fern-sdk-method-name": "deploy_script",},)@@ -695,6 +699,7 @@ async def deploy_script(summary="Run script",description="Run a script",tags=["Scripts"],+ openapi_extra={"x-hidden": True},)@base_router.post("/scripts/{script_id}/run/",diff --git a/skyvern/forge/sdk/workflow/models/code_block_recorder.py b/skyvern/forge/sdk/workflow/models/code_block_recorder.pyindex d514dd626..f07b5fd0e 100644--- a/skyvern/forge/sdk/workflow/models/code_block_recorder.py+++ b/skyvern/forge/sdk/workflow/models/code_block_recorder.py@@ -10,6 +10,7 @@ from typing import Any, Awaitable, Callableimport pydanticimport structlog+from skyvern.forge.sdk.db.datetime_utils import naive_utc_nowfrom skyvern.forge.sdk.db.id import generate_action_idfrom skyvern.webeye.actions.action_types import ActionTypefrom skyvern.webeye.actions.actions import Action, ActionStatus, SelectOption@@ -274,6 +275,7 @@ class _Recorder:description: str | None = None,) -> Any:started = time.monotonic()+ started_wall = naive_utc_now()# Input values may be credentials (incl. derived TOTP codes); never describe them.describe_args = () if action_type == ActionType.INPUT_TEXT else argscommon_fields = dict(@@ -302,6 +304,8 @@ class _Recorder:raisefinally:duration_ms = int((time.monotonic() - started) * 1000)+ action.created_at = started_wall+ action.modified_at = naive_utc_now()if isinstance(action.output, dict):action.output["duration_ms"] = duration_msself.actions.append(action)diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.pyindex 1eb4feb4b..53d298f68 100644--- a/skyvern/forge/sdk/workflow/service.py+++ b/skyvern/forge/sdk/workflow/service.py@@ -18,6 +18,7 @@ from hashlib import sha256from typing import Any, Literal, castimport structlog+from jinja2 import meta as jinja2_metafrom sqlalchemy.exc import IntegrityError, SQLAlchemyError# Import LockError for specific exception handling; fallback for OSS without redis@@ -45,6 +46,7 @@ from skyvern.exceptions import (BrowserSessionNotRenewable,DisabledBlockExecutionError,InvalidCredentialId,+ InvalidWorkflowParameter,MissingValueForParameter,ScriptTerminationException,SkyvernException,@@ -90,6 +92,7 @@ from skyvern.forge.sdk.workflow.browser_profile_key import (build_workflow_browser_session_storage_key,render_browser_profile_key,)+from skyvern.forge.sdk.workflow.context_manager import jinja_sandbox_envfrom skyvern.forge.sdk.workflow.credential_fallback import (VALID_FALLBACK_TRIGGERS,maybe_start_credential_fallback_retry,@@ -196,9 +199,14 @@ from skyvern.services.script_review_cap import ()from skyvern.services.script_reviewer_v3.cohort import is_v3_cohortfrom skyvern.services.script_reviewer_v3.postrun import v3_review_post_run-from skyvern.services.webhook_delivery import PreparedWorkflowWebhook, deliver_webhook_with_retries+from skyvern.services.webhook_delivery import (+ PreparedWorkflowWebhook,+ deliver_webhook_with_retries,+ describe_delivery_error,+)from skyvern.utils.css_selector import build_action_summaries_with_timing # shared with script_servicefrom skyvern.utils.secret_headers import merge_masked_headers+from skyvern.utils.strings import is_uuidfrom skyvern.utils.url_validators import validate_url as validate_url_with_blocked_host_checkfrom skyvern.webeye.actions.action_types import ActionTypefrom skyvern.webeye.browser_state import BrowserState@@ -1794,6 +1802,7 @@ class WorkflowService:)parameter_values = {param.key: value for param, value in workflow_parameter_values}+ await self._validate_bitwarden_item_ids(workflow=workflow, parameter_values=parameter_values)run_credential_parameter_overrides = await self._apply_run_credential_parameter_overrides(workflow=workflow,workflow_run=workflow_run,@@ -1888,6 +1897,53 @@ class WorkflowService:return "value cannot be null"return "database error while saving parameter value"+ async def _validate_bitwarden_item_ids(self, workflow: Workflow, parameter_values: dict[str, Any]) -> None:+ # BitwardenService rejects non-UUID item IDs, so a value already known at run creation and+ # not a UUID can only produce a run that fails at context init — reject it here instead,+ # mirroring WorkflowRunContext._resolve_parameter_value (which needs a worker-side context).+ # Values only resolvable at run time (outputs, context values) are skipped.+ defined_keys = {parameter.key for parameter in workflow.workflow_definition.parameters}+ output_keys: set[str] | None = None+ for parameter in workflow.workflow_definition.parameters:+ if not isinstance(parameter, (BitwardenLoginCredentialParameter, BitwardenCreditCardDataParameter)):+ continue+ source = parameter.bitwarden_item_id+ if not source:+ continue+ if source in parameter_values:+ candidate = parameter_values[source]+ elif source in defined_keys:+ continue+ else:+ if source.endswith("_output"):+ if output_keys is None:+ output_keys = {+ output_parameter.key+ for output_parameter in await self.get_workflow_output_parameters(+ workflow_id=workflow.workflow_id+ )+ }+ if source in output_keys:+ continue+ try:+ referenced_keys = jinja2_meta.find_undeclared_variables(jinja_sandbox_env.parse(source))+ if not referenced_keys <= parameter_values.keys():+ continue+ candidate = jinja_sandbox_env.from_string(source).render(parameter_values)+ except Exception:+ continue+ if not candidate:+ # A falsy login item ID means "no item filter" at secret-fetch time, but the+ # credit-card path requires an item ID and fails context init on a falsy value.+ if isinstance(parameter, BitwardenLoginCredentialParameter):+ continue+ if not isinstance(candidate, str) or not is_uuid(candidate):+ raise InvalidWorkflowParameter(+ expected_parameter_type="Bitwarden item ID (UUID)",+ value=str(candidate),+ workflow_permanent_id=workflow.workflow_permanent_id,+ )+async def _resolve_and_stamp_run_seed(self,*,@@ -8950,13 +9006,14 @@ class WorkflowService:"Workflow webhook delivery failed after attempting delivery",workflow_id=webhook.workflow_id,workflow_run_id=webhook.workflow_run_id,- error=str(e),+ organization_id=webhook.organization_id,+ error=describe_delivery_error(e),exc_info=True,)try:await app.DATABASE.workflow_runs.update_workflow_run(workflow_run_id=webhook.workflow_run_id,- webhook_failure_reason=f"Webhook delivery failed before receiving a response: {e}",+ webhook_failure_reason=f"Webhook delivery failed before receiving a response: {describe_delivery_error(e)}",)except Exception:LOG.warning(@@ -9053,11 +9110,10 @@ class WorkflowService:upload_keys.add(upload_key)continue- # No pre-registered artifact row: a recording attached at browser teardown- # (remote-CDP path) needs a RECORDING artifact created from the on-disk file.- # Upload by path so the bytes stream straight from disk to storage.+ # A teardown-attached recording has no pre-registered artifact row.+ # Prefer collected video bytes; use the on-disk path only when no bytes were returned.video_path = video_artifact.video_path- if not video_path or not os.path.exists(video_path):+ if not video_artifact.video_data and (not video_path or not os.path.exists(video_path)):continueif not last_step_resolved:last_step_resolved = True@@ -9068,16 +9124,23 @@ class WorkflowService:)if last_step is None:LOG.warning(- "Cannot persist path-based recording: no latest step for workflow run",+ "Cannot persist recording: no latest step for workflow run",workflow_run_id=workflow_run.workflow_run_id,video_path=video_path,)continue- artifact_id = await app.ARTIFACT_MANAGER.create_artifact(- step=last_step,- artifact_type=ArtifactType.RECORDING,- path=video_path,- )+ if video_artifact.video_data:+ artifact_id = await app.ARTIFACT_MANAGER.create_artifact(+ step=last_step,+ artifact_type=ArtifactType.RECORDING,+ data=video_artifact.video_data,+ )+ else:+ artifact_id = await app.ARTIFACT_MANAGER.create_artifact(+ step=last_step,+ artifact_type=ArtifactType.RECORDING,+ path=video_path,+ )video_artifact.video_artifact_id = artifact_idupload_keys.add(last_step.task_id)if upload_keys:diff --git a/skyvern/services/task_v2_service.py b/skyvern/services/task_v2_service.pyindex 1810f8ba2..7148d3743 100644--- a/skyvern/services/task_v2_service.py+++ b/skyvern/services/task_v2_service.py@@ -82,7 +82,7 @@ from skyvern.schemas.workflows import (WorkflowDefinitionYAML,WorkflowStatus,)-from skyvern.services.webhook_delivery import deliver_webhook_with_retries+from skyvern.services.webhook_delivery import deliver_webhook_with_retries, describe_delivery_errorfrom skyvern.utils.prompt_engine import load_prompt_with_elementsfrom skyvern.utils.strings import generate_random_stringfrom skyvern.utils.url_validators import validate_fetch_url@@ -2587,14 +2587,36 @@ async def send_task_v2_webhook(task_v2: TaskV2) -> None:payload_length=len(payload),header_keys=sorted(headers.keys()),)- resp = await deliver_webhook_with_retries(- url=task_v2.webhook_callback_url,- payload=payload,- headers=headers,- timeout_seconds=30.0,- organization_id=task_v2.organization_id,- run_id=task_v2.observer_cruise_id,- )+ try:+ resp = await deliver_webhook_with_retries(+ url=task_v2.webhook_callback_url,+ payload=payload,+ headers=headers,+ timeout_seconds=30.0,+ organization_id=task_v2.organization_id,+ run_id=task_v2.observer_cruise_id,+ )+ except Exception as delivery_error:+ LOG.warning(+ "Task v2 webhook delivery failed after attempting delivery",+ task_v2_id=task_v2.observer_cruise_id,+ organization_id=task_v2.organization_id,+ error=describe_delivery_error(delivery_error),+ exc_info=True,+ )+ try:+ await app.DATABASE.observer.update_task_v2(+ task_v2_id=task_v2.observer_cruise_id,+ organization_id=task_v2.organization_id,+ webhook_failure_reason=f"Webhook delivery failed before receiving a response: {describe_delivery_error(delivery_error)}",+ )+ except Exception:+ LOG.warning(+ "Failed to record task v2 webhook delivery error",+ task_v2_id=task_v2.observer_cruise_id,+ exc_info=True,+ )+ raiseif resp.status_code >= 200 and resp.status_code < 300:LOG.info("Task v2 webhook sent successfully",diff --git a/skyvern/services/webhook_delivery.py b/skyvern/services/webhook_delivery.pyindex 2fd91838b..fc89461c6 100644--- a/skyvern/services/webhook_delivery.py+++ b/skyvern/services/webhook_delivery.py@@ -52,6 +52,13 @@ def is_retryable_status(status_code: int) -> bool:return status_code in NON_5XX_RETRYABLE_STATUS_CODES or 500 <= status_code < 600+def describe_delivery_error(exc: Exception) -> str:+ # httpx timeout exceptions stringify to "", which made both persisted+ # failure reasons and retry logs unactionable (SKY-13149).+ text = str(exc).strip()+ return f"{type(exc).__name__}: {text}" if text else type(exc).__name__++def _parse_retry_after(value: str | None) -> float | None:if value is None:return None@@ -139,7 +146,7 @@ async def deliver_webhook_with_retries(attempt=attempt + 1,max_attempts=max_attempts,status_code=status_code,- error=str(last_exc) if last_exc is not None else None,+ error=describe_delivery_error(last_exc) if last_exc is not None else None,sleep_seconds=delay,retry_after_present=last_response is not None and "Retry-After" in last_response.headers,)diff --git a/skyvern/utils/prompt_engine.py b/skyvern/utils/prompt_engine.pyindex 9cf2b8f56..17071ed79 100644--- a/skyvern/utils/prompt_engine.py+++ b/skyvern/utils/prompt_engine.py@@ -232,6 +232,7 @@ def enforce_prompt_ceiling_tracked(if final_token_count <= PROMPT_HARD_CEILING_TOKENS:return prompt, working_kwargsfallback_keys = CEILING_FALLBACK_KEYS_BY_TEMPLATE.get(template_name, [])+ drops_applied = 0for drop_key in fallback_keys:if working_kwargs.get(drop_key) is None:continue@@ -243,6 +244,7 @@ def enforce_prompt_ceiling_tracked(hard_ceiling=PROMPT_HARD_CEILING_TOKENS,)working_kwargs[drop_key] = None+ drops_applied += 1if elements is None:prompt = prompt_engine.load_prompt(template_name, **working_kwargs)else:@@ -250,11 +252,18 @@ def enforce_prompt_ceiling_tracked(final_token_count = count_tokens(prompt)if final_token_count <= PROMPT_HARD_CEILING_TOKENS:return prompt, working_kwargs+ # The breakdown normally stashed on SkyvernContext is computed after this+ # function returns, so the prompt that actually failed never reports one.+ html_token_count = count_tokens(elements) if elements else NoneLOG.error(- "Prompt still exceeds hard ceiling after all fallback drops",+ "Prompt still exceeds hard ceiling",template_name=template_name,final_token_count=final_token_count,hard_ceiling=PROMPT_HARD_CEILING_TOKENS,+ fallback_keys_configured=len(fallback_keys),+ drops_applied=drops_applied,+ html_token_count=html_token_count,+ html_pct=round(html_token_count / final_token_count, 4) if html_token_count and final_token_count else None,)raise SkyvernContextWindowExceededError(prompt_name=template_name)diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex d5475d378..d810658cc 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -1511,7 +1511,13 @@ async def _resolve_collapse_xp_assignment(return assignment-async def _resolve_collapse_gate(task: Task, family_flag: str, log_label: str) -> _CollapseGateResult:+async def _resolve_collapse_gate(+ task: Task,+ family_flag: str,+ log_label: str,+ *,+ consult_assignment: bool = True,+) -> _CollapseGateResult:organization_id = task.organization_idif not organization_id:return _CollapseGateResult(False, None, False)@@ -1538,6 +1544,9 @@ async def _resolve_collapse_gate(task: Task, family_flag: str, log_label: str) -)if not family_enabled:return _CollapseGateResult(False, None, False)+ if not consult_assignment:+ # Family-only mode skips the umbrella (and its memo seed) so sibling families keep their control arms.+ return _CollapseGateResult(family_enabled, None, False)# Cached-script runs skip only the umbrella randomization: they must always be# in-treatment when the family is on, while the family flag stays the kill switch.if script_mode_run:@@ -1561,7 +1570,13 @@ async def _is_collapse_fanout_enabled(task: Task, family_flag: str, log_label: sasync def _is_collapse_select_fanout_enabled(task: Task) -> bool:- return await _is_collapse_fanout_enabled(task, COLLAPSE_SELECT_FANOUT_FLAG, "collapse-select-fanout")+ gate = await _resolve_collapse_gate(+ task,+ COLLAPSE_SELECT_FANOUT_FLAG,+ "collapse-select-fanout",+ consult_assignment=False,+ )+ return gate.family_enabledasync def _is_collapse_custom_select_fanout_enabled(task: Task) -> bool:diff --git a/tests/unit/test_api_docs_taxonomy.py b/tests/unit/test_api_docs_taxonomy.pyindex ed00b67e0..3726aaddc 100644--- a/tests/unit/test_api_docs_taxonomy.py+++ b/tests/unit/test_api_docs_taxonomy.py@@ -45,6 +45,13 @@ RETIRED_TAGS = {"server","scheduler",}+# Sections deliberately hidden from the rendered reference (SKY-13151): ops keep their tag and+# stay in the schema via x-hidden, so the SDK surface is unchanged, but Mintlify renders no section.+HIDDEN_SECTION_TAGS = {+ "Tags",+ "Scripts",+ "Custom LLMs",+}# The endpoints this change re-tagged → their clean resource tag.RETAGGED_PATH_TAGS = {"/v1/folders": "Folders",@@ -84,7 +91,10 @@ def test_no_lowercase_visible_tags() -> None:def test_visible_tags_are_approved_resource_names() -> None:tags = _visible_tags(_committed_spec())- assert {"Folders", "Tags", "Server"} <= tags, "the public sub-resources must each keep a section"+ assert {"Folders", "Server"} <= tags, "the public sub-resources must each keep a section"+ assert tags.isdisjoint(HIDDEN_SECTION_TAGS), (+ f"hidden sections leaked back into the rendered reference: {sorted(tags & HIDDEN_SECTION_TAGS)}"+ )assert tags <= APPROVED_TAGS, (f"unapproved tag(s) — justify and add to APPROVED_TAGS: {sorted(tags - APPROVED_TAGS)}")diff --git a/tests/unit/test_cleanup_browser_video_path_fallback.py b/tests/unit/test_cleanup_browser_video_path_fallback.pyindex 18af64d74..5a210c66a 100644--- a/tests/unit/test_cleanup_browser_video_path_fallback.py+++ b/tests/unit/test_cleanup_browser_video_path_fallback.py@@ -1,9 +1,9 @@-"""Path-fallback behavior for ``Agent.cleanup_browser_and_create_artifacts``.+"""Finalized-byte preference and path-fallback behavior for recording cleanup.The standalone-task cleanup mirrors the workflow path: a recording attached during browser teardown-arrives as ``VideoArtifact(video_path=..., video_artifact_id=None)``; ``update_artifact_data`` no-ops-on a falsy id, so the MP4 must be promoted to a step-scoped RECORDING artifact via-``create_artifact(path=...)`` before the task's task-id drain runs.+arrives as ``VideoArtifact(video_path=..., video_artifact_id=None)``. Finalized ``video_data`` must be+promoted to a step-scoped RECORDING artifact, with ``create_artifact(path=...)`` reserved for artifacts+whose data is empty.OSS-synced: synthetic ids and example.* placeholders only."""@@ -11,12 +11,14 @@ OSS-synced: synthetic ids and example.* placeholders only.from __future__ import annotationsfrom pathlib import Path+from types import SimpleNamespacefrom unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom skyvern.forge.agent import ForgeAgentfrom skyvern.forge.sdk.artifact.models import ArtifactType+from skyvern.forge.sdk.workflow.service import WorkflowServicefrom skyvern.webeye.browser_artifacts import BrowserArtifacts, VideoArtifact@@ -42,6 +44,138 @@ def _browser_state() -> MagicMock:return state+async def test_workflow_cleanup_creates_recording_from_finalized_data(tmp_path: Path) -> None:+ webm = tmp_path / "session.webm"+ webm.write_bytes(b"raw-bytes")+ video_artifacts = [VideoArtifact(video_path=str(webm), video_data=b"finalized-bytes", video_artifact_id=None)]+ last_task = _make_task()+ last_step = _make_step()+ workflow = SimpleNamespace(workflow_id="w_1")+ workflow_run = SimpleNamespace(workflow_run_id="wr_1", organization_id="o_1")++ with patch("skyvern.forge.sdk.workflow.service.app") as mock_app:+ mock_app.BROWSER_MANAGER.get_video_artifacts = AsyncMock(return_value=video_artifacts)+ mock_app.DATABASE.tasks.get_tasks_by_workflow_run_id = AsyncMock(return_value=[last_task])+ mock_app.DATABASE.tasks.get_latest_step = AsyncMock(return_value=last_step)+ mock_app.ARTIFACT_MANAGER.update_artifact_data = AsyncMock()+ mock_app.ARTIFACT_MANAGER.create_artifact = AsyncMock(return_value="a_recording_data")+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks = AsyncMock()++ await WorkflowService().persist_video_data(_browser_state(), workflow, workflow_run)++ mock_app.ARTIFACT_MANAGER.update_artifact_data.assert_not_awaited()+ mock_app.ARTIFACT_MANAGER.create_artifact.assert_awaited_once()+ kwargs = mock_app.ARTIFACT_MANAGER.create_artifact.call_args.kwargs+ assert kwargs["step"] is last_step+ assert kwargs["artifact_type"] == ArtifactType.RECORDING+ assert kwargs["data"] == b"finalized-bytes"+ assert kwargs.get("path") is None+ assert video_artifacts[0].video_artifact_id == "a_recording_data"+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks.assert_awaited_once_with(["tsk_1"])+++async def test_workflow_cleanup_creates_recording_from_finalized_data_when_path_is_missing(tmp_path: Path) -> None:+ missing_webm = tmp_path / "missing.webm"+ assert not missing_webm.exists()+ video_artifacts = [+ VideoArtifact(video_path=str(missing_webm), video_data=b"finalized-bytes", video_artifact_id=None)+ ]+ last_task = _make_task()+ last_step = _make_step()+ workflow = SimpleNamespace(workflow_id="w_1")+ workflow_run = SimpleNamespace(workflow_run_id="wr_1", organization_id="o_1")++ with patch("skyvern.forge.sdk.workflow.service.app") as mock_app:+ mock_app.BROWSER_MANAGER.get_video_artifacts = AsyncMock(return_value=video_artifacts)+ mock_app.DATABASE.tasks.get_tasks_by_workflow_run_id = AsyncMock(return_value=[last_task])+ mock_app.DATABASE.tasks.get_latest_step = AsyncMock(return_value=last_step)+ mock_app.ARTIFACT_MANAGER.update_artifact_data = AsyncMock()+ mock_app.ARTIFACT_MANAGER.create_artifact = AsyncMock(return_value="a_recording_data")+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks = AsyncMock()++ await WorkflowService().persist_video_data(_browser_state(), workflow, workflow_run)++ mock_app.ARTIFACT_MANAGER.create_artifact.assert_awaited_once_with(+ step=last_step,+ artifact_type=ArtifactType.RECORDING,+ data=b"finalized-bytes",+ )+ assert video_artifacts[0].video_artifact_id == "a_recording_data"+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks.assert_awaited_once_with(["tsk_1"])+++async def test_workflow_cleanup_falls_back_to_recording_path_when_data_is_empty(tmp_path: Path) -> None:+ webm = tmp_path / "session.webm"+ webm.write_bytes(b"raw-bytes")+ video_artifacts = [VideoArtifact(video_path=str(webm), video_data=b"", video_artifact_id=None)]+ last_task = _make_task()+ last_step = _make_step()+ workflow = SimpleNamespace(workflow_id="w_1")+ workflow_run = SimpleNamespace(workflow_run_id="wr_1", organization_id="o_1")++ with patch("skyvern.forge.sdk.workflow.service.app") as mock_app:+ mock_app.BROWSER_MANAGER.get_video_artifacts = AsyncMock(return_value=video_artifacts)+ mock_app.DATABASE.tasks.get_tasks_by_workflow_run_id = AsyncMock(return_value=[last_task])+ mock_app.DATABASE.tasks.get_latest_step = AsyncMock(return_value=last_step)+ mock_app.ARTIFACT_MANAGER.update_artifact_data = AsyncMock()+ mock_app.ARTIFACT_MANAGER.create_artifact = AsyncMock(return_value="a_recording_path")+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks = AsyncMock()++ await WorkflowService().persist_video_data(_browser_state(), workflow, workflow_run)++ mock_app.ARTIFACT_MANAGER.update_artifact_data.assert_not_awaited()+ mock_app.ARTIFACT_MANAGER.create_artifact.assert_awaited_once()+ kwargs = mock_app.ARTIFACT_MANAGER.create_artifact.call_args.kwargs+ assert kwargs["step"] is last_step+ assert kwargs["artifact_type"] == ArtifactType.RECORDING+ assert kwargs["path"] == str(webm)+ assert kwargs.get("data") is None+ assert video_artifacts[0].video_artifact_id == "a_recording_path"+ mock_app.ARTIFACT_MANAGER.wait_for_upload_aiotasks.assert_awaited_once_with(["tsk_1"])+++async def test_cleanup_creates_recording_from_finalized_data(tmp_path: Path) -> None:+ webm = tmp_path / "session.webm"+ webm.write_bytes(b"raw-bytes")+ video_artifacts = [VideoArtifact(video_path=str(webm), video_data=b"finalized-bytes", video_artifact_id=None)]++ agent = ForgeAgent()+ task = _make_task()+ last_step = _make_step()+ browser_state = _browser_state()++ with patch("skyvern.forge.agent.app") as mock_app:+ mock_app.BROWSER_MANAGER.cleanup_for_task = AsyncMock(return_value=browser_state)+ mock_app.BROWSER_MANAGER.get_video_artifacts = AsyncMock(return_value=video_artifacts)+ mock_app.BROWSER_MANAGER.get_har_data = AsyncMock(return_value=b"")+ mock_app.BROWSER_MANAGER.get_browser_console_log = AsyncMock(return_value=b"")+ mock_app.ARTIFACT_MANAGER.update_artifact_data = AsyncMock()+ mock_app.ARTIFACT_MANAGER.create_artifact = AsyncMock(return_value="a_recording_data")++ await agent.cleanup_browser_and_create_artifacts(+ close_browser_on_completion=True,+ last_step=last_step,+ task=task,+ )++ mock_app.ARTIFACT_MANAGER.update_artifact_data.assert_not_awaited()+ create_call_args = [+ c+ for c in mock_app.ARTIFACT_MANAGER.create_artifact.await_args_list+ if c.kwargs.get("artifact_type") == ArtifactType.RECORDING+ ]+ assert len(create_call_args) == 1+ kwargs = create_call_args[0].kwargs+ assert kwargs["step"] is last_step+ assert kwargs["data"] == b"finalized-bytes"+ assert kwargs.get("path") is None+ assert video_artifacts[0].video_artifact_id == "a_recording_data"++@pytest.mark.asyncioasync def test_cleanup_creates_recording_from_path_when_id_is_none(tmp_path: Path) -> None:mp4 = tmp_path / "session.mp4"diff --git a/tests/unit/test_collapse_fanout_gates.py b/tests/unit/test_collapse_fanout_gates.pyindex a88859581..4735e4a8d 100644--- a/tests/unit/test_collapse_fanout_gates.py+++ b/tests/unit/test_collapse_fanout_gates.py@@ -1,7 +1,8 @@import asyncio+import inspectfrom types import SimpleNamespacefrom typing import Any-from unittest.mock import MagicMock+from unittest.mock import MagicMock, Mockimport posthogimport pytest@@ -192,13 +193,13 @@ def test_posthog_local_wpid_exclusion_requires_a_present_property() -> None:async def test_collapse_family_and_umbrella_on_uses_workflow_run_id(monkeypatch: pytest.MonkeyPatch) -> None:provider = FakeExperimentationProvider({- handler.COLLAPSE_SELECT_FANOUT_FLAG: True,+ handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,UMBRELLA_FLAG: True,})_set_provider(monkeypatch, provider)- assert await handler._is_collapse_select_fanout_enabled(_task()) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(_task()) is Trueassert _umbrella_calls(provider) == [("unrecorded", UMBRELLA_FLAG, "wr_456", {"organization_id": "o_123"})]@@ -275,7 +276,39 @@ async def test_collapse_gates_share_one_umbrella_cohort(monkeypatch: pytest.Monk@pytest.mark.asyncio-async def test_collapse_umbrella_assignment_stays_sticky_for_run(monkeypatch: pytest.MonkeyPatch) -> None:+ ("family_enabled", "umbrella_enabled", "raises_for", "expected"),+ [+ (True, True, set(), True),+ (True, False, set(), True),+ (True, True, {UMBRELLA_FLAG}, True),+ (False, True, set(), False),+ ],+)+async def test_normal_collapse_gate_ignores_umbrella_assignment(+ monkeypatch: pytest.MonkeyPatch,+ family_enabled: bool,+ umbrella_enabled: bool,+ raises_for: set[str],+ expected: bool,+) -> None:+ provider = FakeExperimentationProvider(+ {+ handler.COLLAPSE_SELECT_FANOUT_FLAG: family_enabled,+ UMBRELLA_FLAG: umbrella_enabled,+ },+ raises_for=raises_for,+ )+ _set_provider(monkeypatch, provider)+ task = _task()++ assert await handler._is_collapse_select_fanout_enabled(task) is expected+ assert _umbrella_calls(provider) == []+ assert task.workflow_run_id not in handler._COLLAPSE_XP_ASSIGNMENT_MEMO+++async def test_normal_collapse_gate_does_not_seed_custom_assignment(monkeypatch: pytest.MonkeyPatch) -> None:provider = FakeExperimentationProvider({handler.COLLAPSE_SELECT_FANOUT_FLAG: True,@@ -286,10 +319,97 @@ async def test_collapse_umbrella_assignment_stays_sticky_for_run(monkeypatch: py_set_provider(monkeypatch, provider)task = _task()+ assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert _umbrella_calls(provider) == []+ assert task.workflow_run_id not in handler._COLLAPSE_XP_ASSIGNMENT_MEMO++ assert await handler._is_collapse_custom_select_fanout_enabled(task) is True+ assert _umbrella_calls(provider) == [("unrecorded", UMBRELLA_FLAG, "wr_456", {"organization_id": "o_123"})]+ assert handler._COLLAPSE_XP_ASSIGNMENT_MEMO[task.workflow_run_id] is True++ provider.results[UMBRELLA_FLAG] = False+ gate = await handler._resolve_collapse_gate(task, CUSTOM_FLAG, "custom-select")+ assert gate == handler._CollapseGateResult(family_enabled=True, assigned=True, gate_error=False)+ assert len(_umbrella_calls(provider)) == 1+++def test_consult_assignment_false_is_keyword_only_and_normal_only() -> None:+ parameter = inspect.signature(handler._resolve_collapse_gate).parameters["consult_assignment"]+ assert parameter.kind is inspect.Parameter.KEYWORD_ONLY+ assert parameter.default is True++ assert inspect.getsource(handler).count("consult_assignment=False") == 1+ assert "consult_assignment=False" in inspect.getsource(handler._is_collapse_select_fanout_enabled)+++async def test_family_only_mode_wins_over_script_mode_pinning(monkeypatch: pytest.MonkeyPatch) -> None:+ # Both branches short-circuit at the same point; family-only must be evaluated first so a+ # non-randomized family never reports an assignment it was never given.+ provider = FakeExperimentationProvider({handler.COLLAPSE_SELECT_FANOUT_FLAG: True, UMBRELLA_FLAG: True})+ _set_provider(monkeypatch, provider)+ task = _task()++ with skyvern_context.scoped(SkyvernContext(script_mode=True)):+ gate = await handler._resolve_collapse_gate(+ task,+ handler.COLLAPSE_SELECT_FANOUT_FLAG,+ "collapse-select-fanout",+ consult_assignment=False,+ )++ assert gate == handler._CollapseGateResult(family_enabled=True, assigned=None, gate_error=False)+ assert _umbrella_calls(provider) == []+ assert task.workflow_run_id not in handler._COLLAPSE_XP_ASSIGNMENT_MEMO+++async def test_custom_select_executor_fails_closed_on_umbrella_error(monkeypatch: pytest.MonkeyPatch) -> None:+ provider = FakeExperimentationProvider(+ {handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True},+ raises_for={UMBRELLA_FLAG},+ )+ _set_provider(monkeypatch, provider)+ logger = CaptureLogger()+ monkeypatch.setattr(handler, "LOG", logger)+ task = _task()+ get_option_candidates = Mock(side_effect=AssertionError("must not be called when the gate fails closed"))++ result = await handler._select_deterministic_custom_option(+ target_value="United States",+ get_option_candidates=get_option_candidates,+ field_context=None,+ page=Mock(),+ get_skyvern_element=Mock(),+ task=task,+ execute=True,+ )++ assert result is None+ get_option_candidates.assert_not_called()+ [outcome_record] = [record for record in logger.records if record[1] == "custom_select_family_outcome"]+ _, _, fields = outcome_record+ assert fields["family_gate_enabled"] is False+ assert fields["assigned"] is None+ assert fields["gate_error"] is True+ assert fields["outcome"] == handler.CustomSelectFamilyOutcome.llm_fallback_gate_error.value+++async def test_collapse_umbrella_assignment_stays_sticky_for_run(monkeypatch: pytest.MonkeyPatch) -> None:+ provider = FakeExperimentationProvider(+ {+ handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,+ UMBRELLA_FLAG: True,+ }+ )+ _set_provider(monkeypatch, provider)+ task = _task()+with skyvern_context.scoped(SkyvernContext()):- assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueprovider.results[UMBRELLA_FLAG] = False- assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueassert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueassert _umbrella_calls(provider) == [("unrecorded", UMBRELLA_FLAG, "wr_456", {"organization_id": "o_123"})]@@ -299,7 +419,6 @@ async def test_collapse_umbrella_assignment_stays_sticky_for_run(monkeypatch: pyasync def test_collapse_umbrella_assignment_survives_context_replacement(monkeypatch: pytest.MonkeyPatch) -> None:provider = FakeExperimentationProvider({- handler.COLLAPSE_SELECT_FANOUT_FLAG: True,handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,UMBRELLA_FLAG: True,}@@ -308,10 +427,10 @@ async def test_collapse_umbrella_assignment_survives_context_replacement(monkeyptask = _task()with skyvern_context.scoped(SkyvernContext(workflow_run_id=task.workflow_run_id)):- assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueskyvern_context.replace(SkyvernContext(workflow_run_id=task.workflow_run_id))provider.results[UMBRELLA_FLAG] = False- assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueassert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueassert _umbrella_calls(provider) == [("unrecorded", UMBRELLA_FLAG, "wr_456", {"organization_id": "o_123"})]@@ -323,7 +442,7 @@ async def test_collapse_umbrella_never_records_against_ambient_child_context() -> None:provider = FakeExperimentationProvider({- handler.COLLAPSE_SELECT_FANOUT_FLAG: True,+ handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,UMBRELLA_FLAG: True,})@@ -333,7 +452,7 @@ async def test_collapse_umbrella_never_records_against_ambient_child_context(task = _task(workflow_run_id="wr_parent")with skyvern_context.scoped(SkyvernContext(workflow_run_id="wr_child")) as context:- assert await handler._is_collapse_select_fanout_enabled(task) is True+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Trueassert handler._COLLAPSE_XP_ASSIGNMENT_MEMO["wr_parent"] is Trueassert UMBRELLA_FLAG not in context.feature_flag_entries@@ -356,7 +475,7 @@ async def test_collapse_umbrella_never_records_against_ambient_child_context(async def test_collapse_umbrella_first_writer_logs_once_without_lock(monkeypatch: pytest.MonkeyPatch) -> None:provider = FakeExperimentationProvider({- handler.COLLAPSE_SELECT_FANOUT_FLAG: True,+ handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,UMBRELLA_FLAG: True,})@@ -366,8 +485,8 @@ async def test_collapse_umbrella_first_writer_logs_once_without_lock(monkeypatchtask = _task()assert await asyncio.gather(- handler._is_collapse_select_fanout_enabled(task),- handler._is_collapse_select_fanout_enabled(task),+ handler._is_collapse_custom_select_fanout_enabled(task),+ handler._is_collapse_custom_select_fanout_enabled(task),) == [True, True]assert len(_umbrella_calls(provider)) == 2assert len([record for record in logger.records if record[1] == "collapse_xp_assignment"]) == 1@@ -377,7 +496,7 @@ async def test_collapse_umbrella_first_writer_logs_once_without_lock(monkeypatchasync def test_collapse_umbrella_error_pins_run_to_control(monkeypatch: pytest.MonkeyPatch) -> None:provider = FakeExperimentationProvider({- handler.COLLAPSE_SELECT_FANOUT_FLAG: True,+ handler.COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG: True,handler.COLLAPSE_AUTOCOMPLETE_FANOUT_FLAG: True,UMBRELLA_FLAG: True,},@@ -389,10 +508,10 @@ async def test_collapse_umbrella_error_pins_run_to_control(monkeypatch: pytest.Mtask = _task()with skyvern_context.scoped(SkyvernContext(workflow_run_id=task.workflow_run_id)) as context:- assert await handler._is_collapse_select_fanout_enabled(task) is False+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Falseassert UMBRELLA_FLAG not in context.feature_flag_entriesprovider.raises_for.remove(UMBRELLA_FLAG)- assert await handler._is_collapse_select_fanout_enabled(task) is False+ assert await handler._is_collapse_custom_select_fanout_enabled(task) is Falseassert await handler._is_collapse_autocomplete_fanout_enabled(task) is Falseassert _umbrella_calls(provider) == [("unrecorded", UMBRELLA_FLAG, "wr_456", {"organization_id": "o_123"})]diff --git a/tests/unit/test_load_prompt_with_elements_ceiling.py b/tests/unit/test_load_prompt_with_elements_ceiling.pyindex d58e0a394..21dda7556 100644--- a/tests/unit/test_load_prompt_with_elements_ceiling.py+++ b/tests/unit/test_load_prompt_with_elements_ceiling.py@@ -196,6 +196,36 @@ def test_enforce_prompt_ceiling_tracked_noop_under_ceiling() -> None:assert post_kwargs["data_extraction_schema"] == {"type": "object"}+def test_enforce_prompt_ceiling_tracked_error_log_reports_zero_drops_and_html_share(+ small_prompt_ceiling: int,+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ from skyvern.exceptions import SkyvernContextWindowExceededError+ from skyvern.forge.prompts import prompt_engine as engine_module+ from skyvern.utils import prompt_engine++ log = MagicMock()+ monkeypatch.setattr(prompt_engine, "LOG", log)++ # check-user-goal has no CEILING_FALLBACK_KEYS_BY_TEMPLATE entry, so no drop is attempted+ with pytest.raises(SkyvernContextWindowExceededError):+ prompt_engine.enforce_prompt_ceiling_tracked(+ "lorem " * (small_prompt_ceiling + 100),+ prompt_engine=engine_module,+ template_name="check-user-goal",+ kwargs={"action_history": "some history"},+ elements="<a>link</a>",+ )++ message = log.error.call_args.args[0]+ fields = log.error.call_args.kwargs+ assert "after all fallback drops" not in message+ assert fields["fallback_keys_configured"] == 0+ assert fields["drops_applied"] == 0+ assert fields["html_token_count"] > 0+ assert 0 < fields["html_pct"] <= 1.0++def test_load_prompt_with_elements_tracked_reports_dropped_keys(small_prompt_ceiling: int) -> None:from skyvern.forge.prompts import prompt_engine as engine_modulefrom skyvern.utils.prompt_engine import PROMPT_HARD_CEILING_TOKENS, load_prompt_with_elements_trackeddiff --git a/tests/unit/test_normal_select_deterministic.py b/tests/unit/test_normal_select_deterministic.pyindex 6b16bf878..48b881f3f 100644--- a/tests/unit/test_normal_select_deterministic.py+++ b/tests/unit/test_normal_select_deterministic.py@@ -99,6 +99,8 @@ async def _run_normal_select(selected_index: int | None = None,llm_response: dict | None = None,evaluate_side_effect: BaseException | None = None,+ collapse_gate: AsyncMock | None = None,+ agent_function: object | None = None,) -> tuple[list, MagicMock, AsyncMock]:provider = SimpleNamespace(is_feature_enabled_cached=AsyncMock(return_value=feature_enabled),@@ -106,8 +108,11 @@ async def _run_normal_select()normal_select_llm = AsyncMock(return_value=llm_response or {"value": "fallback", "index": None})- monkeypatch.setattr(handler.app, "EXPERIMENTATION_PROVIDER", provider)- monkeypatch.setattr(handler.app, "AGENT_FUNCTION", AgentFunction())+ if collapse_gate is None:+ monkeypatch.setattr(handler.app, "EXPERIMENTATION_PROVIDER", provider)+ else:+ monkeypatch.setattr(handler, "_is_collapse_select_fanout_enabled", collapse_gate)+ monkeypatch.setattr(handler.app, "AGENT_FUNCTION", agent_function or AgentFunction())monkeypatch.setattr(handler.app, "NORMAL_SELECT_AGENT_LLM_API_HANDLER", normal_select_llm)monkeypatch.setattr(handler.prompt_engine, "load_prompt", MagicMock(return_value="prompt"))monkeypatch.setattr(handler.skyvern_context, "ensure_context", MagicMock(return_value=SimpleNamespace(tz_info=UTC)))@@ -157,15 +162,20 @@ async def test_normal_select_exact_or_stem_match_skips_llm(options: list[dict],selected_value: str,) -> None:+ gate = AsyncMock(return_value=True)+ action = _select_action(target)result, locator, normal_select_llm = await _run_normal_select(monkeypatch,feature_enabled=True,- action=_select_action(target),+ action=action,options=options,selected_value=selected_value,+ collapse_gate=gate,)assert handler._normal_select_successful(result)+ assert not action.has_mini_agent+ gate.assert_awaited_once()locator.select_option.assert_awaited_once_with(value=selected_value,timeout=handler.settings.BROWSER_ACTION_TIMEOUT_MS,@@ -255,6 +265,7 @@ async def test_normal_select_unsafe_match_falls_back_to_llm(options: list[dict],llm_value: str,) -> None:+ gate = AsyncMock(return_value=True)action = _select_action(target)result, locator, normal_select_llm = await _run_normal_select(monkeypatch,@@ -263,10 +274,12 @@ async def test_normal_select_unsafe_match_falls_back_to_llm(options=options,selected_value=llm_value,llm_response={"value": llm_value, "index": None},+ collapse_gate=gate,)assert handler._normal_select_successful(result)assert action.has_mini_agent is True+ gate.assert_awaited_once()locator.select_option.assert_awaited_once_with(value=llm_value, timeout=handler.settings.BROWSER_ACTION_TIMEOUT_MS)normal_select_llm.assert_awaited_once()@@ -409,6 +422,8 @@ async def test_normal_select_readback_index_mismatch_falls_back_to_llm(monkeypat@pytest.mark.asyncioasync def test_normal_select_flag_off_uses_llm_path(monkeypatch: pytest.MonkeyPatch) -> None:+ gate = AsyncMock(return_value=False)+ resolver = AsyncMock()action = _select_action("United States")result, locator, normal_select_llm = await _run_normal_select(monkeypatch,@@ -417,10 +432,14 @@ async def test_normal_select_flag_off_uses_llm_path(monkeypatch: pytest.MonkeyPaoptions=[{"optionIndex": 0, "text": "United States", "value": "US"}],selected_value="US",llm_response={"value": "US", "index": None},+ collapse_gate=gate,+ agent_function=SimpleNamespace(resolve_field_option=resolver),)assert handler._normal_select_successful(result)assert action.has_mini_agent is True+ gate.assert_awaited_once()+ resolver.assert_not_awaited()locator.select_option.assert_awaited_once_with(value="US", timeout=handler.settings.BROWSER_ACTION_TIMEOUT_MS)normal_select_llm.assert_awaited_once()diff --git a/tests/unit/test_run_script_lifecycle.py b/tests/unit/test_run_script_lifecycle.pyindex 18ec958fe..9eeb721b3 100644--- a/tests/unit/test_run_script_lifecycle.py+++ b/tests/unit/test_run_script_lifecycle.py@@ -9,6 +9,7 @@ Cleanup is best-effort: a cleanup/release failure must never replace the script'from __future__ import annotationsimport asyncio+from datetime import datetimefrom pathlib import Pathfrom unittest.mock import AsyncMock, MagicMock@@ -16,7 +17,8 @@ import pytestfrom skyvern.forge import appfrom skyvern.forge.sdk.core import skyvern_context-from skyvern.services.script_service import run_script+from skyvern.schemas.workflows import BlockType+from skyvern.services.script_service import _create_workflow_block_run_and_task, run_scriptfrom skyvern.webeye.real_browser_manager import RealBrowserManagerSUCCESS_SCRIPT = "async def run_workflow(parameters=None):\n return None\n"@@ -46,6 +48,35 @@ def _write_script(tmp_path: Path, body: str) -> str:return str(path)+async def test_cached_script_container_task_stamps_started_at(monkeypatch: pytest.MonkeyPatch) -> None:+ workflow_run_block = MagicMock(workflow_run_block_id="wrb_1")+ created_task = MagicMock(task_id="task_1", started_at=datetime(2026, 1, 1), workflow_run_id="wr_1")+ step = MagicMock(step_id="step_1")+ database = MagicMock()+ database.observer.create_workflow_run_block = AsyncMock(return_value=workflow_run_block)+ database.observer.update_workflow_run_block = AsyncMock()+ database.tasks.create_task = AsyncMock(return_value=created_task)+ database.tasks.update_task = AsyncMock(return_value=created_task)+ database.tasks.create_step = AsyncMock(return_value=step)+ monkeypatch.setattr(app, "DATABASE", database)+ create_video_artifact = AsyncMock()+ take_screenshot = AsyncMock()+ monkeypatch.setattr("skyvern.services.script_service._create_video_artifact", create_video_artifact)+ monkeypatch.setattr("skyvern.services.script_service._take_workflow_run_block_screenshot", take_screenshot)+ skyvern_context.set(skyvern_context.SkyvernContext(organization_id="org_1", workflow_run_id="wr_1"))++ result = await _create_workflow_block_run_and_task(BlockType.NAVIGATION)++ assert result == ("wrb_1", "task_1", "step_1")+ database.tasks.create_task.assert_awaited_once()+ assert database.tasks.create_task.await_args.kwargs["status"] == "running"+ database.tasks.update_task.assert_not_awaited()+ setup_task = create_video_artifact.await_args.kwargs["task"]+ assert setup_task.started_at is not None+ assert setup_task is created_task++@pytest.mark.asyncioasync def test_run_script_standalone_success_runs_terminal_cleanup(monkeypatch: pytest.MonkeyPatch, tmp_path: Pathdiff --git a/tests/unit/test_webhook_delivery.py b/tests/unit/test_webhook_delivery.pyindex fdf5eb8eb..bd6df7435 100644--- a/tests/unit/test_webhook_delivery.py+++ b/tests/unit/test_webhook_delivery.py@@ -42,3 +42,11 @@ async def test_valid_https_url_reaches_delivery(monkeypatch: pytest.MonkeyPatch))assert out.status_code == 200deliver.assert_awaited_once()+++def test_describe_delivery_error_uses_type_name_for_empty_message() -> None:+ assert webhook_delivery.describe_delivery_error(httpx.ReadTimeout("")) == "ReadTimeout"+++def test_describe_delivery_error_includes_message_when_present() -> None:+ assert webhook_delivery.describe_delivery_error(httpx.ConnectError("boom")) == "ConnectError: boom"diff --git a/tests/unit/test_webhook_failure_reason.py b/tests/unit/test_webhook_failure_reason.pynew file mode 100644index 000000000..7ce188ef0--- /dev/null+++ b/tests/unit/test_webhook_failure_reason.py@@ -0,0 +1,151 @@+from __future__ import annotations++from types import SimpleNamespace+from unittest.mock import AsyncMock, MagicMock++import httpx+import pytest++from skyvern.exceptions import FailedToSendWebhook+from skyvern.forge import agent as agent_module+from skyvern.forge.agent import ForgeAgent+from skyvern.services import task_v2_service+++def _make_task() -> MagicMock:+ task = MagicMock()+ task.task_id = "tsk_1"+ task.organization_id = "o_1"+ task.webhook_callback_url = "https://example.com/hook"+ return task+++def task_webhook_agent(monkeypatch: pytest.MonkeyPatch) -> tuple[ForgeAgent, AsyncMock]:+ agent = ForgeAgent()+ update_task = AsyncMock()++ monkeypatch.setattr(agent_module.app.DATABASE.tasks, "get_latest_step", AsyncMock(return_value=None))+ monkeypatch.setattr(agent_module.app.DATABASE.tasks, "update_task", update_task)+ monkeypatch.setattr(+ agent,+ "build_task_response",+ AsyncMock(return_value=SimpleNamespace(model_dump_json=lambda **_kw: "{}")),+ )+ monkeypatch.setattr(agent_module.run_service, "get_run_response", AsyncMock(return_value=None))+ monkeypatch.setattr(+ agent_module,+ "generate_skyvern_webhook_signature",+ lambda payload, api_key: SimpleNamespace(+ payload_for_log='{"safe":true}',+ headers={"x-skyvern-signature": "sig"},+ signed_payload='{"signed":true}',+ ),+ )+ return agent, update_task+++async def test_task_webhook_delivery_exception_persists_failure_reason(+ task_webhook_agent: tuple[ForgeAgent, AsyncMock],+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ agent, update_task = task_webhook_agent+ monkeypatch.setattr(+ agent_module,+ "deliver_webhook_with_retries",+ AsyncMock(side_effect=httpx.ReadTimeout("")),+ )++ with pytest.raises(FailedToSendWebhook):+ await agent.execute_task_webhook(task=_make_task(), api_key="api-key")++ update_task.assert_awaited_once()+ reason = update_task.await_args.kwargs["webhook_failure_reason"]+ assert "ReadTimeout" in reason+++async def test_task_webhook_still_raises_when_failure_reason_recording_fails(+ task_webhook_agent: tuple[ForgeAgent, AsyncMock],+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ agent, update_task = task_webhook_agent+ update_task.side_effect = RuntimeError("db pool exhausted")+ monkeypatch.setattr(+ agent_module,+ "deliver_webhook_with_retries",+ AsyncMock(side_effect=httpx.ConnectError("unreachable")),+ )++ with pytest.raises(FailedToSendWebhook):+ await agent.execute_task_webhook(task=_make_task(), api_key="api-key")+++async def test_task_webhook_non_delivery_exception_does_not_persist_failure_reason(+ task_webhook_agent: tuple[ForgeAgent, AsyncMock],+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ agent, update_task = task_webhook_agent+ deliver = AsyncMock()+ monkeypatch.setattr(agent_module, "deliver_webhook_with_retries", deliver)++ def _broken_signature(payload: object, api_key: str) -> None:+ raise TypeError("payload not serializable")++ monkeypatch.setattr(agent_module, "generate_skyvern_webhook_signature", _broken_signature)++ with pytest.raises(FailedToSendWebhook):+ await agent.execute_task_webhook(task=_make_task(), api_key="api-key")++ deliver.assert_not_awaited()+ update_task.assert_not_awaited()+++def _make_task_v2() -> MagicMock:+ task_v2 = MagicMock()+ task_v2.observer_cruise_id = "oc_1"+ task_v2.organization_id = "o_1"+ task_v2.webhook_callback_url = "https://example.com/hook"+ task_v2.model_dump_json = lambda **_kw: "{}"+ return task_v2+++async def test_task_v2_webhook_delivery_exception_persists_failure_reason(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ update_task_v2 = AsyncMock()+ monkeypatch.setattr(+ task_v2_service.app.DATABASE.organizations,+ "get_valid_org_auth_token",+ AsyncMock(return_value=SimpleNamespace(token="api-key")),+ )+ monkeypatch.setattr(task_v2_service.app.DATABASE.observer, "update_task_v2", update_task_v2)+ monkeypatch.setattr(+ task_v2_service,+ "build_task_v2_run_response",+ AsyncMock(return_value=SimpleNamespace(model_dump_json=lambda **_kw: "{}")),+ )+ monkeypatch.setattr(+ task_v2_service,+ "generate_skyvern_webhook_signature",+ lambda payload, api_key: SimpleNamespace(+ payload_for_log='{"safe":true}',+ headers={"x-skyvern-signature": "sig"},+ signed_payload='{"signed":true}',+ ),+ )+ monkeypatch.setattr(+ task_v2_service,+ "deliver_webhook_with_retries",+ AsyncMock(side_effect=httpx.ReadTimeout("")),+ )++ with pytest.raises(FailedToSendWebhook):+ await task_v2_service.send_task_v2_webhook(_make_task_v2())++ update_task_v2.assert_awaited_once()+ reason = update_task_v2.await_args.kwargs["webhook_failure_reason"]+ assert "ReadTimeout" in reasondiff --git a/tests/unit/test_workflow_run_parameter_batching.py b/tests/unit/test_workflow_run_parameter_batching.pyindex 3f4e2eb54..ba0bac20b 100644--- a/tests/unit/test_workflow_run_parameter_batching.py+++ b/tests/unit/test_workflow_run_parameter_batching.py@@ -15,11 +15,21 @@ from unittest.mock import AsyncMock, patchimport pytestfrom sqlalchemy.exc import IntegrityError-from skyvern.exceptions import InvalidCredentialId, MissingValueForParameter, WorkflowRunParameterPersistenceError+from skyvern.exceptions import (+ InvalidCredentialId,+ InvalidWorkflowParameter,+ MissingValueForParameter,+ WorkflowRunParameterPersistenceError,+)from skyvern.forge.sdk.core import skyvern_contextfrom skyvern.forge.sdk.core.skyvern_context import SkyvernContextfrom skyvern.forge.sdk.db.enums import WorkflowRunTriggerType-from skyvern.forge.sdk.workflow.models.parameter import WorkflowParameter, WorkflowParameterType+from skyvern.forge.sdk.workflow.models.parameter import (+ BitwardenCreditCardDataParameter,+ BitwardenLoginCredentialParameter,+ WorkflowParameter,+ WorkflowParameterType,+)from skyvern.forge.sdk.workflow.models.tags import CallerType, TagSource, TagWriteContextfrom skyvern.forge.sdk.workflow.models.workflow import WorkflowDefinition, WorkflowRequestBodyfrom skyvern.forge.sdk.workflow.service import WorkflowService@@ -51,6 +61,7 @@ def _make_service_with_mocks(persist_browser_session: bool = False,browser_profile_id: str | None = None,cdp_connect_headers: dict[str, str] | None = None,+ definition_parameters: list | None = None,) -> tuple[WorkflowService, SimpleNamespace, SimpleNamespace]:"""Helper to build a WorkflowService with mocked internals for setup_workflow_run tests."""service = WorkflowService()@@ -71,7 +82,7 @@ def _make_service_with_mocks(code_version=None,adaptive_caching=False,sequential_key=None,- workflow_definition=WorkflowDefinition(blocks=[], parameters=[]),+ workflow_definition=WorkflowDefinition(blocks=[], parameters=definition_parameters or []),)workflow_run = SimpleNamespace(workflow_run_id="wr_test", workflow_permanent_id="wpid_test")@@ -87,6 +98,7 @@ def _make_service_with_mocks(else:service.create_workflow_run_parameter = AsyncMock() # type: ignore[method-assign]service.mark_workflow_run_as_failed = AsyncMock(return_value=workflow_run) # type: ignore[method-assign]+ service.get_workflow_output_parameters = AsyncMock(return_value=[]) # type: ignore[method-assign]# Seed resolution is exercised in test_seed_precedence_engine; here it is a pass-through so these# setup_workflow_run tests (param batching / tagging / trigger types) don't need seed fixtures.service._resolve_and_stamp_run_seed = AsyncMock(return_value=workflow_run) # type: ignore[method-assign]@@ -917,3 +929,205 @@ async def test_setup_workflow_run_inherits_browser_profile_for_normal_run() -> Nassert request.browser_profile_id == "bp_workflow"assert request.cdp_connect_headers == {"authorization": "Bearer workflow"}+++def _make_bitwarden_login_parameter(bitwarden_item_id: str | None) -> BitwardenLoginCredentialParameter:+ now = datetime.now(tz=timezone.utc)+ return BitwardenLoginCredentialParameter(+ bitwarden_login_credential_parameter_id="blcp_test",+ workflow_id="wf_test",+ key="bw_login",+ bitwarden_client_id_aws_secret_key="client_id",+ bitwarden_client_secret_aws_secret_key="client_secret",+ bitwarden_master_password_aws_secret_key="master_password",+ bitwarden_item_id=bitwarden_item_id,+ created_at=now,+ modified_at=now,+ )+++def _make_bitwarden_credit_card_parameter(bitwarden_item_id: str) -> BitwardenCreditCardDataParameter:+ now = datetime.now(tz=timezone.utc)+ return BitwardenCreditCardDataParameter(+ bitwarden_credit_card_data_parameter_id="bccdp_test",+ workflow_id="wf_test",+ key="bw_credit_card",+ bitwarden_client_id_aws_secret_key="client_id",+ bitwarden_client_secret_aws_secret_key="client_secret",+ bitwarden_master_password_aws_secret_key="master_password",+ bitwarden_collection_id="collection",+ bitwarden_item_id=bitwarden_item_id,+ created_at=now,+ modified_at=now,+ )+++async def _run_setup_with_bitwarden_item_id(+ *,+ bitwarden_item_id: str | None,+ request_data: dict | None,+ workflow_parameters: list[WorkflowParameter] | None = None,+ output_parameter_keys: list[str] | None = None,+ credential_parameter: BitwardenCreditCardDataParameter | None = None,+) -> tuple[SimpleNamespace, SimpleNamespace]:+ service, organization, workflow_run = _make_service_with_mocks(+ workflow_parameters=workflow_parameters or [],+ definition_parameters=[credential_parameter or _make_bitwarden_login_parameter(bitwarden_item_id)],+ )+ service.get_workflow_output_parameters = AsyncMock( # type: ignore[method-assign]+ return_value=[SimpleNamespace(key=key) for key in output_parameter_keys or []]+ )+ with patch("skyvern.forge.sdk.workflow.service.app") as mock_app:+ mock_app.DATABASE.workflows.get_browser_action_policy = AsyncMock(return_value=None)+ mock_app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached = AsyncMock(return_value=False)+ mock_app.AGENT_FUNCTION.should_use_flex_llm_routing = AsyncMock(return_value=False)+ mock_app.AGENT_FUNCTION.is_browser_memory_engine_enabled = AsyncMock(return_value=False)+ mock_app.DATABASE.tags.apply_run_tag_changes = AsyncMock()+ result = await service.setup_workflow_run(+ request_id="req_test",+ workflow_request=WorkflowRequestBody(data=request_data),+ workflow_permanent_id="wpid_test",+ organization=organization,+ )+ return result, service+++async def test_setup_rejects_non_uuid_bitwarden_item_id_from_run_parameter_template() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="{{ item_ref }}",+ request_data={"item_ref": "test"},+ workflow_parameters=[_make_workflow_parameter("item_ref")],+ )+++async def test_setup_rejects_non_uuid_bitwarden_item_id_from_bare_key_reference() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="item_ref",+ request_data={"item_ref": "test"},+ workflow_parameters=[_make_workflow_parameter("item_ref")],+ )+++async def test_setup_rejects_non_uuid_literal_bitwarden_item_id() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(bitwarden_item_id="not-a-uuid", request_data=None)+++async def test_setup_marks_run_failed_on_invalid_bitwarden_item_id() -> None:+ service, organization, _ = _make_service_with_mocks(+ workflow_parameters=[],+ definition_parameters=[_make_bitwarden_login_parameter("not-a-uuid")],+ )+ with patch("skyvern.forge.sdk.workflow.service.app") as mock_app:+ mock_app.DATABASE.workflows.get_browser_action_policy = AsyncMock(return_value=None)+ mock_app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached = AsyncMock(return_value=False)+ mock_app.AGENT_FUNCTION.should_use_flex_llm_routing = AsyncMock(return_value=False)+ mock_app.DATABASE.tags.apply_run_tag_changes = AsyncMock()+ with pytest.raises(InvalidWorkflowParameter):+ await service.setup_workflow_run(+ request_id="req_test",+ workflow_request=WorkflowRequestBody(data=None),+ workflow_permanent_id="wpid_test",+ organization=organization,+ )+ service.mark_workflow_run_as_failed.assert_awaited_once()+ failure_reason = service.mark_workflow_run_as_failed.await_args.kwargs["failure_reason"]+ assert "Bitwarden item ID" in failure_reason+++async def test_setup_accepts_valid_uuid_bitwarden_item_id_from_run_parameter() -> None:+ result, _ = await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="{{ item_ref }}",+ request_data={"item_ref": "3d8b857e-31d0-44b2-8276-b28900b7f112"},+ workflow_parameters=[_make_workflow_parameter("item_ref")],+ )+ assert result.workflow_run_id == "wr_test"+++async def test_setup_skips_bitwarden_item_id_only_resolvable_at_run_time() -> None:+ for source in ("{{ login_block.item_id }}", None, ""):+ result, _ = await _run_setup_with_bitwarden_item_id(bitwarden_item_id=source, request_data=None)+ assert result.workflow_run_id == "wr_test"+++async def test_setup_skips_bitwarden_item_id_referencing_real_output_parameter() -> None:+ result, _ = await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="extract_output",+ request_data=None,+ output_parameter_keys=["extract_output"],+ )+ assert result.workflow_run_id == "wr_test"+++async def test_setup_rejects_output_suffixed_literal_without_matching_output_parameter() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(bitwarden_item_id="test_output", request_data=None)+++async def test_setup_rejects_non_string_bitwarden_item_id_from_run_parameter() -> None:+ for value in (123, True, ["3d8b857e-31d0-44b2-8276-b28900b7f112"]):+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="{{ item_ref }}",+ request_data={"item_ref": value},+ workflow_parameters=[+ _make_workflow_parameter("item_ref", workflow_parameter_type=WorkflowParameterType.JSON)+ ],+ )+++async def test_setup_skips_falsy_bare_key_item_id_for_login_parameter() -> None:+ result, _ = await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="item_ref",+ request_data={"item_ref": 0},+ workflow_parameters=[_make_workflow_parameter("item_ref", workflow_parameter_type=WorkflowParameterType.JSON)],+ )+ assert result.workflow_run_id == "wr_test"+++async def test_setup_rejects_falsy_template_item_id_for_login_parameter() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="{{ item_ref }}",+ request_data={"item_ref": 0},+ workflow_parameters=[+ _make_workflow_parameter("item_ref", workflow_parameter_type=WorkflowParameterType.JSON)+ ],+ )+++async def test_setup_rejects_falsy_item_id_for_credit_card_parameter() -> None:+ for value in (0, False):+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id=None,+ request_data={"item_ref": value},+ workflow_parameters=[+ _make_workflow_parameter("item_ref", workflow_parameter_type=WorkflowParameterType.JSON)+ ],+ credential_parameter=_make_bitwarden_credit_card_parameter("item_ref"),+ )+++async def test_setup_rejects_composite_template_item_id_with_known_parameters() -> None:+ with pytest.raises(InvalidWorkflowParameter, match="Bitwarden item ID"):+ await _run_setup_with_bitwarden_item_id(+ bitwarden_item_id="{{ prefix }}-{{ suffix }}",+ request_data={"prefix": "abc", "suffix": "def"},+ workflow_parameters=[_make_workflow_parameter("prefix"), _make_workflow_parameter("suffix")],+ )diff --git a/tests/unit/test_workflow_webhook_delivery.py b/tests/unit/test_workflow_webhook_delivery.pyindex 81fe3a3e7..11911ea3b 100644--- a/tests/unit/test_workflow_webhook_delivery.py+++ b/tests/unit/test_workflow_webhook_delivery.py@@ -172,3 +172,18 @@ async def test_execute_workflow_webhook_propagates_pre_delivery_infra_failure(deliver.assert_not_awaited()update_run.assert_not_awaited()+++async def test_execute_workflow_webhook_records_exception_type_for_empty_message(+ webhook_service: tuple[WorkflowService, AsyncMock, AsyncMock],+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ svc, _build_response, update_run = webhook_service+ deliver = AsyncMock(side_effect=httpx.ReadTimeout(""))+ monkeypatch.setattr(service_module, "deliver_webhook_with_retries", deliver)++ await svc.execute_workflow_webhook(_workflow_run())++ update_run.assert_awaited_once()+ assert "ReadTimeout" in update_run.await_args.kwargs["webhook_failure_reason"]diff --git a/tests/unit/workflow/test_code_block_recorder.py b/tests/unit/workflow/test_code_block_recorder.pyindex 9b0615866..50896599b 100644--- a/tests/unit/workflow/test_code_block_recorder.py+++ b/tests/unit/workflow/test_code_block_recorder.py@@ -4,16 +4,20 @@ from __future__ import annotationsimport asyncioimport json+from collections.abc import AsyncIterator+from contextlib import asynccontextmanagerfrom datetime import datetime, timezonefrom types import SimpleNamespacefrom unittest.mock import AsyncMockimport pytest+from sqlalchemy import selectfrom skyvern.core.script_generations.skyvern_page import SkyvernPagefrom skyvern.forge import appfrom skyvern.forge.agent import ForgeAgentfrom skyvern.forge.sdk.copilot.code_block_steps import _METHOD_ACTION_TYPES+from skyvern.forge.sdk.db.agent_db import AgentDBfrom skyvern.forge.sdk.db.models import ActionModelfrom skyvern.forge.sdk.db.utils import hydrate_actionfrom skyvern.forge.sdk.models import StepStatus@@ -115,6 +119,44 @@ class FakePage:return None+@asynccontextmanager+async def _recorded_action_db() -> AsyncIterator[AgentDB]:+ db = AgentDB("sqlite+aiosqlite:///:memory:")+ async with db.engine.begin() as connection:+ await connection.run_sync(ActionModel.__table__.create)+ try:+ yield db+ finally:+ await db.engine.dispose()+++async def _record_timed_action() -> Action:+ recorder = _Recorder()++ async def delayed_call() -> None:+ await asyncio.sleep(0.01)++ await recorder.record(ActionType.CLICK, "locator.click", "#go", delayed_call, (), {})+ action = recorder.actions[0]+ action.task_id = "tsk_timing"+ action.step_id = "stp_timing"+ action.step_order = 0+ return action+++async def test_recorded_action_has_wall_clock_timestamps_and_duration() -> None:+ action = await _record_timed_action()++ assert action.created_at is not None+ assert action.modified_at is not None+ assert action.created_at < action.modified_at+ assert action.created_at.tzinfo is None+ assert action.modified_at.tzinfo is None+ assert isinstance(action.output, dict)+ assert "duration_ms" in action.output++@pytest.mark.asyncioasync def test_records_goto_click_fill_with_types_and_order() -> None:page = RecordingPage(FakePage())@@ -894,6 +936,72 @@ async def test_streamed_write_precedes_screenshot_backfilled_by_batch(monkeypatcassert writes[0].action_id == writes[-1].action_id+async def test_reupsert_preserves_action_end_timestamp_and_backfills_screenshot() -> None:+ async with _recorded_action_db() as db:+ action = await _record_timed_action()+ stamped_end = action.modified_at+ await db.workflow_params.upsert_recorded_action(action)++ await asyncio.sleep(0.01)+ action.screenshot_artifact_id = "artifact_timing"+ await db.workflow_params.upsert_recorded_action(action)++ async with db.Session() as session:+ row = (await session.scalars(select(ActionModel).where(ActionModel.action_id == action.action_id))).one()++ assert row.modified_at == stamped_end+ assert row.screenshot_artifact_id == "artifact_timing"+++async def test_recorded_action_timestamps_round_trip_through_hydration() -> None:+ async with _recorded_action_db() as db:+ action = await _record_timed_action()+ await db.workflow_params.upsert_recorded_action(action)++ async with db.Session() as session:+ row = (await session.scalars(select(ActionModel).where(ActionModel.action_id == action.action_id))).one()+ hydrated = hydrate_action(row)++ assert row.created_at == action.created_at+ assert row.modified_at == action.modified_at+ assert hydrated.created_at == action.created_at+ assert hydrated.modified_at == action.modified_at+++async def test_unstamped_action_reupsert_keeps_bump_behavior() -> None:+ async with _recorded_action_db() as db:+ action = Action(+ action_id="act_unstamped",+ action_type=ActionType.CLICK,+ status=ActionStatus.completed,+ task_id="tsk_unstamped",+ step_id="stp_unstamped",+ step_order=0,+ action_order=0,+ )+ assert action.created_at is None+ assert action.modified_at is None+ await db.workflow_params.upsert_recorded_action(action)++ async with db.Session() as session:+ first = (await session.scalars(select(ActionModel).where(ActionModel.action_id == action.action_id))).one()+ first_modified = first.modified_at++ await asyncio.sleep(0.01)+ action.screenshot_artifact_id = "artifact_unstamped"+ await db.workflow_params.upsert_recorded_action(action)++ async with db.Session() as session:+ row = (await session.scalars(select(ActionModel).where(ActionModel.action_id == action.action_id))).one()++ assert row.screenshot_artifact_id == "artifact_unstamped"+ assert row.modified_at > first_modified+ assert row.modified_at.tzinfo is None++@pytest.mark.asyncioasync def test_streamed_write_masks_secrets(monkeypatch: pytest.MonkeyPatch) -> None:"""Secrets must be masked on the streamed path too, not only in the end-of-block batch."""