Skip to content

Automate browser based workflows with AI

suchintan.vibe code user goal check (#2349)

Shuchang Zhenged4280153f5d
diff --git a/alembic/versions/2025_05_15_1507-d90177b2b935_add_include_action_history_in_.py b/alembic/versions/2025_05_15_1507-d90177b2b935_add_include_action_history_in_.py
new file mode 100644
index 000000000..791e15cf4
--- /dev/null
+++ b/alembic/versions/2025_05_15_1507-d90177b2b935_add_include_action_history_in_.py
@@ -0,0 +1,35 @@
+"""add_include_action_history_in_verification_to_tasks
+
+Revision ID: d90177b2b935
+Revises: 11b84609ef08
+Create Date: 2025-05-15 15:07:22.825001+00:00
+
+"""
+
+from typing import Sequence, Union
+
+import sqlalchemy as sa
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision: str = "d90177b2b935"
+down_revision: Union[str, None] = "11b84609ef08"
+branch_labels: Union[str, Sequence[str], None] = None
+depends_on: Union[str, Sequence[str], None] = None
+
+
+def upgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column("tasks", sa.Column("include_action_history_in_verification", sa.Boolean(), nullable=True))
+ op.add_column(
+ "workflow_run_blocks", sa.Column("include_action_history_in_verification", sa.Boolean(), nullable=True)
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column("workflow_run_blocks", "include_action_history_in_verification")
+ op.drop_column("tasks", "include_action_history_in_verification")
+ # ### end Alembic commands ###
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 206f9166f..234af7b31 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -139,6 +139,7 @@ export type CreateTaskRequest = {
totp_verification_url?: string | null;
totp_identifier?: string | null;
application?: string | null;
+ include_action_history_in_verification?: boolean | null;
};
export type User = {
diff --git a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx
index 1609d9d4d..8631daa3e 100644
--- a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx
+++ b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskForm.tsx
@@ -38,7 +38,7 @@ import {
CreateNewTaskFormValues,
} from "./taskFormTypes";
import { ProxySelector } from "@/components/ProxySelector";
-
+import { Switch } from "@/components/ui/switch";
type Props = {
initialValues: CreateNewTaskFormValues;
};
@@ -80,6 +80,8 @@ function createTaskRequestObject(
extracted_information_schema: extractedInformationSchema,
totp_identifier: transform(formValues.totpIdentifier),
error_code_mapping: errorCodeMapping,
+ include_action_history_in_verification:
+ formValues.includeActionHistoryInVerification,
};
}
@@ -425,6 +427,36 @@ function CreateNewTaskForm({ initialValues }: Props) {
{isActive("advanced") && (
<div className="space-y-6">
<div className="space-y-4">
+ <FormField
+ control={form.control}
+ name="includeActionHistoryInVerification"
+ render={({ field }) => (
+ <FormItem>
+ <div className="flex gap-16">
+ <FormLabel>
+ <div className="w-72">
+ <h1 className="text-lg">Include Action History</h1>
+ <h2 className="text-base text-slate-400">
+ Whether to include action history when verifying
+ the task completion.
+ </h2>
+ </div>
+ </FormLabel>
+ <div className="w-full">
+ <FormControl>
+ <Switch
+ checked={field.value ?? false}
+ onCheckedChange={(checked) => {
+ field.onChange(checked);
+ }}
+ />
+ </FormControl>
+ <FormMessage />
+ </div>
+ </div>
+ </FormItem>
+ )}
+ />
<FormField
control={form.control}
name="maxStepsOverride"
diff --git a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskFormPage.tsx b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskFormPage.tsx
index cfb670995..50f05b5b2 100644
--- a/skyvern-frontend/src/routes/tasks/create/CreateNewTaskFormPage.tsx
+++ b/skyvern-frontend/src/routes/tasks/create/CreateNewTaskFormPage.tsx
@@ -61,6 +61,7 @@ function CreateNewTaskFormPage() {
totpIdentifier: null,
webhookCallbackUrl: null,
proxyLocation: null,
+ includeActionHistoryInVerification: null,
}}
/>
</div>
@@ -127,6 +128,9 @@ function CreateNewTaskFormPage() {
maxStepsOverride,
totpIdentifier: data.workflow_definition.blocks[0].totp_identifier,
errorCodeMapping: JSON.stringify(errorCodeMapping, null, 2),
+ includeActionHistoryInVerification:
+ data.workflow_definition.blocks[0]
+ .include_action_history_in_verification,
}}
/>
</div>
diff --git a/skyvern-frontend/src/routes/tasks/create/SavedTaskForm.tsx b/skyvern-frontend/src/routes/tasks/create/SavedTaskForm.tsx
index 05fc82206..8b6e7ac9a 100644
--- a/skyvern-frontend/src/routes/tasks/create/SavedTaskForm.tsx
+++ b/skyvern-frontend/src/routes/tasks/create/SavedTaskForm.tsx
@@ -99,6 +99,8 @@ function createTaskTemplateRequestObject(values: SavedTaskFormValues) {
max_steps_per_run: values.maxStepsOverride,
totp_identifier: values.totpIdentifier,
error_code_mapping: safeParseMaybeJSONString(values.errorCodeMapping),
+ include_action_history_in_verification:
+ values.includeActionHistoryInVerification,
},
],
},
diff --git a/skyvern-frontend/src/routes/tasks/create/retry/RetryTask.tsx b/skyvern-frontend/src/routes/tasks/create/retry/RetryTask.tsx
index 3a2ad368d..6755b5d1e 100644
--- a/skyvern-frontend/src/routes/tasks/create/retry/RetryTask.tsx
+++ b/skyvern-frontend/src/routes/tasks/create/retry/RetryTask.tsx
@@ -42,6 +42,8 @@ function RetryTask() {
? JSON.stringify(task.request.error_code_mapping, null, 2)
: "",
proxyLocation: task.request.proxy_location ?? null,
+ includeActionHistoryInVerification:
+ task.request.include_action_history_in_verification ?? false,
}}
/>
</div>
diff --git a/skyvern-frontend/src/routes/tasks/create/taskFormTypes.ts b/skyvern-frontend/src/routes/tasks/create/taskFormTypes.ts
index a9a4262ab..efafcbcfe 100644
--- a/skyvern-frontend/src/routes/tasks/create/taskFormTypes.ts
+++ b/skyvern-frontend/src/routes/tasks/create/taskFormTypes.ts
@@ -14,6 +14,7 @@ const createNewTaskFormSchemaBase = z.object({
totpIdentifier: z.string().or(z.null()),
errorCodeMapping: z.string().or(z.null()),
proxyLocation: z.nativeEnum(ProxyLocation).or(z.null()),
+ includeActionHistoryInVerification: z.boolean().or(z.null()).default(false),
});
const savedTaskFormSchemaBase = createNewTaskFormSchemaBase.extend({
diff --git a/skyvern-frontend/src/routes/tasks/detail/TaskParameters.tsx b/skyvern-frontend/src/routes/tasks/detail/TaskParameters.tsx
index be09695c8..49300b066 100644
--- a/skyvern-frontend/src/routes/tasks/detail/TaskParameters.tsx
+++ b/skyvern-frontend/src/routes/tasks/detail/TaskParameters.tsx
@@ -3,6 +3,7 @@ import { TaskApiResponse } from "@/api/types";
import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";
import { Input } from "@/components/ui/input";
import { Skeleton } from "@/components/ui/skeleton";
+import { Switch } from "@/components/ui/switch";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
import { useQuery } from "@tanstack/react-query";
@@ -123,6 +124,22 @@ function TaskParameters() {
</div>
<Input value={task.request.webhook_callback_url ?? ""} readOnly />
</div>
+ <div className="flex gap-16">
+ <div className="w-72">
+ <h1 className="text-lg">Include Action History</h1>
+ <h2 className="text-base text-slate-400">
+ Include the action history in the completion verification
+ </h2>
+ </div>
+ <div className="w-full">
+ <Switch
+ checked={
+ task.request.include_action_history_in_verification ?? false
+ }
+ disabled
+ />
+ </div>
+ </div>
</section>
);
}
diff --git a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
index 7d43ce509..b99086e90 100644
--- a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
@@ -24,6 +24,8 @@ export const baseHelpTooltipContent = {
continueOnFailure:
"Allow the workflow to continue if it encounters a failure.",
cacheActions: "Cache the actions of this block.",
+ includeActionHistoryInVerification:
+ "Include the action history in the completion verification.",
} as const;
export const basePlaceholderContent = {
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationNode.tsx
index c025ed6f1..2169bb4bb 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationNode.tsx
@@ -56,6 +56,7 @@ function NavigationNode({ id, data }: NodeProps<NavigationNode>) {
totpIdentifier: data.totpIdentifier,
completeCriterion: data.completeCriterion,
terminateCriterion: data.terminateCriterion,
+ includeActionHistoryInVerification: data.includeActionHistoryInVerification,
});
const deleteNodeCallback = useDeleteNodeCallback();
@@ -257,6 +258,31 @@ function NavigationNode({ id, data }: NodeProps<NavigationNode>) {
)}
</div>
<Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Include Action History
+ </Label>
+ <HelpTooltip
+ content={
+ helpTooltips["navigation"][
+ "includeActionHistoryInVerification"
+ ]
+ }
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.includeActionHistoryInVerification}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "includeActionHistoryInVerification",
+ checked,
+ );
+ }}
+ />
+ </div>
+ </div>
<div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
index 16d4166f7..109c66343 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
@@ -15,6 +15,7 @@ export type NavigationNodeData = NodeBaseData & {
totpVerificationUrl: string | null;
totpIdentifier: string | null;
cacheActions: boolean;
+ includeActionHistoryInVerification: boolean;
};
export type NavigationNode = Node<NavigationNodeData, "navigation">;
@@ -36,6 +37,7 @@ export const navigationNodeDefaultData: NavigationNodeData = {
totpIdentifier: null,
continueOnFailure: false,
cacheActions: false,
+ includeActionHistoryInVerification: false,
} as const;
export function isNavigationNode(node: Node): node is NavigationNode {
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
index 490240559..54b7af963 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/TaskNode.tsx
@@ -66,6 +66,7 @@ function TaskNode({ id, data }: NodeProps<TaskNode>) {
errorCodeMapping: data.errorCodeMapping,
totpVerificationUrl: data.totpVerificationUrl,
totpIdentifier: data.totpIdentifier,
+ includeActionHistoryInVerification: data.includeActionHistoryInVerification,
});
function handleChange(key: string, value: unknown) {
@@ -290,6 +291,31 @@ function TaskNode({ id, data }: NodeProps<TaskNode>) {
)}
</div>
<Separator />
+ <div className="flex items-center justify-between">
+ <div className="flex gap-2">
+ <Label className="text-xs font-normal text-slate-300">
+ Include Action History
+ </Label>
+ <HelpTooltip
+ content={
+ helpTooltips["task"][
+ "includeActionHistoryInVerification"
+ ]
+ }
+ />
+ </div>
+ <div className="w-52">
+ <Switch
+ checked={inputs.includeActionHistoryInVerification}
+ onCheckedChange={(checked) => {
+ handleChange(
+ "includeActionHistoryInVerification",
+ checked,
+ );
+ }}
+ />
+ </div>
+ </div>
<div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/types.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/types.ts
index ce5d16a99..f35cf1bf5 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/types.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/TaskNode/types.ts
@@ -17,6 +17,7 @@ export type TaskNodeData = NodeBaseData & {
totpVerificationUrl: string | null;
totpIdentifier: string | null;
cacheActions: boolean;
+ includeActionHistoryInVerification: boolean;
};
export type TaskNode = Node<TaskNodeData, "task">;
@@ -40,6 +41,7 @@ export const taskNodeDefaultData: TaskNodeData = {
totpIdentifier: null,
continueOnFailure: false,
cacheActions: false,
+ includeActionHistoryInVerification: false,
} as const;
export function isTaskNode(node: Node): node is TaskNode {
diff --git a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
index 19ba1f86c..6c42d2c4d 100644
--- a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
@@ -232,6 +232,8 @@ function convertToNode(
cacheActions: block.cache_actions,
completeCriterion: block.complete_criterion ?? "",
terminateCriterion: block.terminate_criterion ?? "",
+ includeActionHistoryInVerification:
+ block.include_action_history_in_verification ?? false,
},
};
}
@@ -304,6 +306,8 @@ function convertToNode(
maxStepsOverride: block.max_steps_per_run ?? null,
completeCriterion: block.complete_criterion ?? "",
terminateCriterion: block.terminate_criterion ?? "",
+ includeActionHistoryInVerification:
+ block.include_action_history_in_verification ?? false,
},
};
}
@@ -975,6 +979,8 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
totp_identifier: node.data.totpIdentifier,
totp_verification_url: node.data.totpVerificationUrl,
cache_actions: node.data.cacheActions,
+ include_action_history_in_verification:
+ node.data.includeActionHistoryInVerification,
};
}
case "taskv2": {
@@ -1046,6 +1052,8 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
cache_actions: node.data.cacheActions,
complete_criterion: node.data.completeCriterion,
terminate_criterion: node.data.terminateCriterion,
+ include_action_history_in_verification:
+ node.data.includeActionHistoryInVerification,
};
}
case "extraction": {
@@ -1703,6 +1711,8 @@ function convertBlocksToBlockYAML(
totp_identifier: block.totp_identifier,
totp_verification_url: block.totp_verification_url,
cache_actions: block.cache_actions,
+ include_action_history_in_verification:
+ block.include_action_history_in_verification,
};
return blockYaml;
}
@@ -1765,6 +1775,8 @@ function convertBlocksToBlockYAML(
cache_actions: block.cache_actions,
complete_criterion: block.complete_criterion,
terminate_criterion: block.terminate_criterion,
+ include_action_history_in_verification:
+ block.include_action_history_in_verification,
};
return blockYaml;
}
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
index 5f11e1a76..3eaf897dd 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts
@@ -40,6 +40,7 @@ export type WorkflowRunBlock = {
data_schema: object | Array<unknown> | string | null;
terminate_criterion: string | null;
complete_criterion: string | null;
+ include_action_history_in_verification: boolean | null;
actions: Array<ActionsApiResponse> | null;
recipients?: Array<string> | null;
attachments?: Array<string> | null;
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
index 35dbc719d..95f17a180 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
@@ -251,6 +251,7 @@ export type TaskBlock = WorkflowBlockBase & {
totp_verification_url?: string | null;
totp_identifier?: string | null;
cache_actions: boolean;
+ include_action_history_in_verification: boolean;
};
export type Taskv2Block = WorkflowBlockBase & {
@@ -363,6 +364,7 @@ export type NavigationBlock = WorkflowBlockBase & {
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
+ include_action_history_in_verification: boolean;
};
export type ExtractionBlock = WorkflowBlockBase & {
diff --git a/skyvern-frontend/src/routes/workflows/types/workflowYamlTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowYamlTypes.ts
index e309e0769..792638400 100644
--- a/skyvern-frontend/src/routes/workflows/types/workflowYamlTypes.ts
+++ b/skyvern-frontend/src/routes/workflows/types/workflowYamlTypes.ts
@@ -134,6 +134,7 @@ export type TaskBlockYAML = BlockYAMLBase & {
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
+ include_action_history_in_verification: boolean;
};
export type Taskv2BlockYAML = BlockYAMLBase & {
@@ -184,6 +185,7 @@ export type NavigationBlockYAML = BlockYAMLBase & {
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
+ include_action_history_in_verification: boolean;
};
export type ExtractionBlockYAML = BlockYAMLBase & {
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/TaskBlockParameters.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/TaskBlockParameters.tsx
index eef2a6af1..af367640d 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/TaskBlockParameters.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/TaskBlockParameters.tsx
@@ -3,6 +3,7 @@ import { Input } from "@/components/ui/input";
import { CodeEditor } from "@/routes/workflows/components/CodeEditor";
import { WorkflowRunBlock } from "../types/workflowRunTypes";
import { isTaskVariantBlock, WorkflowBlockTypes } from "../types/workflowTypes";
+import { Switch } from "@/components/ui/switch";
type Props = {
block: WorkflowRunBlock;
@@ -27,6 +28,10 @@ function TaskBlockParameters({ block }: Props) {
const showValidationParameters =
block.block_type === WorkflowBlockTypes.Validation;
+ const showIncludeActionHistoryInVerification =
+ block.block_type === WorkflowBlockTypes.Task ||
+ block.block_type === WorkflowBlockTypes.Navigation;
+
return (
<>
<div className="flex gap-16">
@@ -44,7 +49,7 @@ function TaskBlockParameters({ block }: Props) {
<div className="w-80">
<h1 className="text-lg">Navigation Goal</h1>
<h2 className="text-base text-slate-400">
- Where should Skyvern go and what should Skyvern do?
+ What should Skyvern do on this page?
</h2>
</div>
<AutoResizingTextarea value={block.navigation_goal ?? ""} readOnly />
@@ -129,6 +134,23 @@ function TaskBlockParameters({ block }: Props) {
/>
</div>
) : null}
+
+ {showIncludeActionHistoryInVerification ? (
+ <div className="flex gap-16">
+ <div className="w-80">
+ <h1 className="text-lg">Include Action History</h1>
+ <h2 className="text-base text-slate-400">
+ Whether to include action history in the completion verification
+ </h2>
+ </div>
+ <div className="w-full">
+ <Switch
+ checked={block.include_action_history_in_verification ?? false}
+ disabled
+ />
+ </div>
+ </div>
+ ) : null}
</>
);
}
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index 81df94c31..39fd990d2 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -172,6 +172,7 @@ class ForgeAgent:
retry=task_retry,
max_steps_per_run=task_block.max_steps_per_run,
error_code_mapping=task_block.error_code_mapping,
+ include_action_history_in_verification=task_block.include_action_history_in_verification,
)
LOG.info(
"Created a new task for workflow run",
@@ -226,6 +227,7 @@ class ForgeAgent:
extracted_information_schema=task_request.extracted_information_schema,
error_code_mapping=task_request.error_code_mapping,
application=task_request.application,
+ include_action_history_in_verification=task_request.include_action_history_in_verification,
)
LOG.info(
"Created new task",
@@ -1033,6 +1035,7 @@ class ForgeAgent:
for result in results:
result.step_retry_number = step.retry_index
result.step_order = step.order
+ step.output = detailed_agent_step_output.to_agent_step_output()
action_results.extend(results)
# Check the last result for this action. If that succeeded, assume the entire action is successful
if results and results[-1].success:
@@ -1462,8 +1465,9 @@ class ForgeAgent:
)
return actions
- @staticmethod
- async def complete_verify(page: Page, scraped_page: ScrapedPage, task: Task, step: Step) -> CompleteVerifyResult:
+ async def complete_verify(
+ self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step
+ ) -> CompleteVerifyResult:
LOG.info(
"Checking if user goal is achieved after re-scraping the page",
task_id=task.task_id,
@@ -1477,6 +1481,10 @@ class ForgeAgent:
scraped_page_refreshed = await scraped_page.refresh(draw_boxes=False, scroll=scroll)
+ actions_and_results_str = ""
+ if task.include_action_history_in_verification:
+ actions_and_results_str = await self._get_action_results(task, current_step=step)
+
verification_prompt = load_prompt_with_elements(
scraped_page=scraped_page_refreshed,
prompt_engine=prompt_engine,
@@ -1484,6 +1492,7 @@ class ForgeAgent:
navigation_goal=task.navigation_goal,
navigation_payload=task.navigation_payload,
complete_criterion=task.complete_criterion,
+ action_history=actions_and_results_str,
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
)
@@ -1496,12 +1505,11 @@ class ForgeAgent:
)
return CompleteVerifyResult.model_validate(verification_result)
- @staticmethod
async def check_user_goal_complete(
- page: Page, scraped_page: ScrapedPage, task: Task, step: Step
+ self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step
) -> CompleteAction | None:
try:
- verification_result = await app.agent.complete_verify(
+ verification_result = await self.complete_verify(
page=page,
scraped_page=scraped_page,
task=task,
@@ -1878,11 +1886,20 @@ class ForgeAgent:
current_context.totp_codes.pop(task.task_id)
return final_navigation_payload
- async def _get_action_results(self, task: Task) -> str:
+ async def _get_action_results(self, task: Task, current_step: Step | None = None) -> str:
+ """
+ Get the action results from the last app.SETTINGS.PROMPT_ACTION_HISTORY_WINDOW steps.
+ If current_step is provided, the current executing step will be included in the action history.
+ Default is excluding the current executing step from the action history.
+ """
+
# Get action results from the last app.SETTINGS.PROMPT_ACTION_HISTORY_WINDOW steps
steps = await app.DATABASE.get_task_steps(task_id=task.task_id, organization_id=task.organization_id)
# the last step is always the newly created one and it should be excluded from the history window
window_steps = steps[-1 - settings.PROMPT_ACTION_HISTORY_WINDOW : -1]
+ if current_step:
+ window_steps.append(current_step)
+
actions_and_results: list[tuple[Action, list[ActionResult]]] = []
for window_step in window_steps:
if window_step.output and window_step.output.actions_and_results:
diff --git a/skyvern/forge/prompts/skyvern/check-user-goal.j2 b/skyvern/forge/prompts/skyvern/check-user-goal.j2
index bc13bf161..7aa5d9b07 100644
--- a/skyvern/forge/prompts/skyvern/check-user-goal.j2
+++ b/skyvern/forge/prompts/skyvern/check-user-goal.j2
@@ -23,6 +23,12 @@ Complete Criterion:
```
{{ complete_criterion }}
```{% endif %}
+{% if action_history %}
+Action History:
+```
+{{ action_history }}
+```
+{% endif %}
Elements on the page:
```
diff --git a/skyvern/forge/sdk/db/client.py b/skyvern/forge/sdk/db/client.py
index 823ccc78e..a916c94d1 100644
--- a/skyvern/forge/sdk/db/client.py
+++ b/skyvern/forge/sdk/db/client.py
@@ -139,6 +139,7 @@ class AgentDB:
error_code_mapping: dict[str, str] | None = None,
task_type: str = TaskType.general,
application: str | None = None,
+ include_action_history_in_verification: bool | None = None,
) -> Task:
try:
async with self.Session() as session:
@@ -164,6 +165,7 @@ class AgentDB:
max_steps_per_run=max_steps_per_run,
error_code_mapping=error_code_mapping,
application=application,
+ include_action_history_in_verification=include_action_history_in_verification,
)
session.add(new_task)
await session.commit()
@@ -2564,6 +2566,7 @@ class AgentDB:
wait_sec: int | None = None,
description: str | None = None,
block_workflow_run_id: str | None = None,
+ include_action_history_in_verification: bool | None = None,
) -> WorkflowRunBlock:
async with self.Session() as session:
workflow_run_block = (
@@ -2604,6 +2607,8 @@ class AgentDB:
workflow_run_block.description = description
if block_workflow_run_id:
workflow_run_block.block_workflow_run_id = block_workflow_run_id
+ if include_action_history_in_verification is not None:
+ workflow_run_block.include_action_history_in_verification = include_action_history_in_verification
await session.commit()
await session.refresh(workflow_run_block)
else:
diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py
index dd5b8783a..793217b11 100644
--- a/skyvern/forge/sdk/db/models.py
+++ b/skyvern/forge/sdk/db/models.py
@@ -83,6 +83,7 @@ class TaskModel(Base):
errors = Column(JSON, default=[], nullable=False)
max_steps_per_run = Column(Integer, nullable=True)
application = Column(String, nullable=True)
+ include_action_history_in_verification = Column(Boolean, default=False, nullable=True)
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False, index=True)
modified_at = Column(
DateTime,
@@ -532,6 +533,7 @@ class WorkflowRunBlockModel(Base):
workflow_run_block_id = Column(String, primary_key=True, default=generate_workflow_run_block_id)
workflow_run_id = Column(String, nullable=False)
+ include_action_history_in_verification = Column(Boolean, default=False, nullable=True)
# this is the inner workflow run id of the taskv2 block
block_workflow_run_id = Column(String, nullable=True)
parent_workflow_run_block_id = Column(String, nullable=True)
diff --git a/skyvern/forge/sdk/db/utils.py b/skyvern/forge/sdk/db/utils.py
index 590a233bd..8d9fd3b65 100644
--- a/skyvern/forge/sdk/db/utils.py
+++ b/skyvern/forge/sdk/db/utils.py
@@ -71,6 +71,7 @@ def convert_to_task(task_obj: TaskModel, debug_enabled: bool = False, workflow_p
url=task_obj.url,
complete_criterion=task_obj.complete_criterion,
terminate_criterion=task_obj.terminate_criterion,
+ include_action_history_in_verification=task_obj.include_action_history_in_verification,
webhook_callback_url=task_obj.webhook_callback_url,
totp_verification_url=task_obj.totp_verification_url,
totp_identifier=task_obj.totp_identifier,
@@ -411,6 +412,7 @@ def convert_to_workflow_run_block(
body=workflow_run_block_model.body,
created_at=workflow_run_block_model.created_at,
modified_at=workflow_run_block_model.modified_at,
+ include_action_history_in_verification=workflow_run_block_model.include_action_history_in_verification,
)
if task:
block.url = task.url
diff --git a/skyvern/forge/sdk/models.py b/skyvern/forge/sdk/models.py
index 1091dac76..8043ffb5e 100644
--- a/skyvern/forge/sdk/models.py
+++ b/skyvern/forge/sdk/models.py
@@ -79,7 +79,11 @@ class Step(BaseModel):
if output is not None and status is None:
raise ValueError(f"cant_set_output_without_updating_status({self.step_id})")
- if self.output is not None and output is not None:
+ if (
+ old_status not in [StepStatus.running, StepStatus.created]
+ and self.output is not None
+ and output is not None
+ ):
raise ValueError(f"cant_override_output({self.step_id})")
if is_last is False:
diff --git a/skyvern/forge/sdk/schemas/tasks.py b/skyvern/forge/sdk/schemas/tasks.py
index e09b63c88..23209202b 100644
--- a/skyvern/forge/sdk/schemas/tasks.py
+++ b/skyvern/forge/sdk/schemas/tasks.py
@@ -90,6 +90,11 @@ class TaskBase(BaseModel):
description="The application for which the task is running",
examples=["forms"],
)
+ include_action_history_in_verification: bool | None = Field(
+ default=False,
+ description="Whether to include the action history when verifying the task is complete",
+ examples=[True, False],
+ )
class TaskRequest(TaskBase):
diff --git a/skyvern/forge/sdk/schemas/workflow_runs.py b/skyvern/forge/sdk/schemas/workflow_runs.py
index cd8fed847..981dd98d4 100644
--- a/skyvern/forge/sdk/schemas/workflow_runs.py
+++ b/skyvern/forge/sdk/schemas/workflow_runs.py
@@ -35,6 +35,7 @@ class WorkflowRunBlock(BaseModel):
actions: list[Action] = []
created_at: datetime
modified_at: datetime
+ include_action_history_in_verification: bool | None = False
# for loop block
loop_values: list[Any] | None = None
diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py
index f3f523344..a2e4e33a3 100644
--- a/skyvern/forge/sdk/workflow/models/block.py
+++ b/skyvern/forge/sdk/workflow/models/block.py
@@ -367,6 +367,7 @@ class BaseTaskBlock(Block):
totp_identifier: str | None = None
cache_actions: bool = False
complete_verification: bool = True
+ include_action_history_in_verification: bool = False
def get_all_parameters(
self,
@@ -544,6 +545,7 @@ class BaseTaskBlock(Block):
workflow_run_block_id=workflow_run_block_id,
task_id=task.task_id,
organization_id=organization_id,
+ include_action_history_in_verification=self.include_action_history_in_verification,
)
current_running_task = task
organization = await app.DATABASE.get_organization(organization_id=workflow_run.organization_id)
diff --git a/skyvern/forge/sdk/workflow/models/yaml.py b/skyvern/forge/sdk/workflow/models/yaml.py
index 5fbc908e8..126295589 100644
--- a/skyvern/forge/sdk/workflow/models/yaml.py
+++ b/skyvern/forge/sdk/workflow/models/yaml.py
@@ -143,6 +143,7 @@ class TaskBlockYAML(BlockYAML):
complete_criterion: str | None = None
terminate_criterion: str | None = None
complete_verification: bool = True
+ include_action_history_in_verification: bool = False
class ForLoopBlockYAML(BlockYAML):
@@ -288,6 +289,7 @@ class NavigationBlockYAML(BlockYAML):
complete_criterion: str | None = None
terminate_criterion: str | None = None
complete_verification: bool = True
+ include_action_history_in_verification: bool = False
class ExtractionBlockYAML(BlockYAML):
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py
index fdd7da1ca..192edd065 100644
--- a/skyvern/forge/sdk/workflow/service.py
+++ b/skyvern/forge/sdk/workflow/service.py
@@ -1621,6 +1621,7 @@ class WorkflowService:
complete_criterion=block_yaml.complete_criterion,
terminate_criterion=block_yaml.terminate_criterion,
complete_verification=block_yaml.complete_verification,
+ include_action_history_in_verification=block_yaml.include_action_history_in_verification,
)
elif block_yaml.block_type == BlockType.FOR_LOOP:
loop_blocks = [
@@ -1816,6 +1817,7 @@ class WorkflowService:
complete_criterion=block_yaml.complete_criterion,
terminate_criterion=block_yaml.terminate_criterion,
complete_verification=block_yaml.complete_verification,
+ include_action_history_in_verification=block_yaml.include_action_history_in_verification,
)
elif block_yaml.block_type == BlockType.EXTRACTION:
diff --git a/skyvern/schemas/runs.py b/skyvern/schemas/runs.py
index 02a8bb21f..7c2e54ee0 100644
--- a/skyvern/schemas/runs.py
+++ b/skyvern/schemas/runs.py
@@ -225,6 +225,9 @@ class TaskRunRequest(BaseModel):
description="ID of an existing browser session to reuse, having it continue from the current screen state",
)
publish_workflow: bool = Field(default=False, description="Whether to publish this task as a reusable workflow. ")
+ include_action_history_in_verification: bool = Field(
+ default=False, description="Whether to include action history when verifying that the task is complete"
+ )
@field_validator("url", "webhook_url", "totp_url")
@classmethod