Skip to content

Automate browser based workflows with AI

revert: light mode v2 token system + hardcode sweep (#10910) (#6163)

Aaron Perezaa3f8ffb2051
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.json
index 9b64da9eb..b8fc02b4c 100644
--- a/docs/api-reference/openapi.json
+++ b/docs/api-reference/openapi.json
@@ -10468,8 +10468,8 @@
},
"engine": {
"$ref": "#/components/schemas/RunEngine",
- "description": "\nThe engine that powers the agent task. The default value is `skyvern-2.0`, the latest Skyvern agent that performs pretty well with complex and multi-step tasks. `skyvern-1.0` is good for simple tasks like filling a form, or searching for information on Google. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.\n",
- "default": "skyvern-2.0"
+ "description": "\nThe engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.\n",
+ "default": "skyvern-1.0"
},
"title": {
"type": "string",
@@ -10580,7 +10580,8 @@
"publish_workflow": {
"type": "boolean",
"title": "Publish Workflow",
- "description": "Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.",
+ "description": "Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.",
+ "deprecated": true,
"default": false
},
"include_action_history_in_verification": {
diff --git a/docs/cloud/building-workflows/configure-blocks.mdx b/docs/cloud/building-workflows/configure-blocks.mdx
index 2d623ae26..50629dea6 100644
--- a/docs/cloud/building-workflows/configure-blocks.mdx
+++ b/docs/cloud/building-workflows/configure-blocks.mdx
@@ -54,7 +54,7 @@ Browser-based blocks (Browser Task, Browser Action, Extraction, Login, File Down
| Field | Description |
|-------|-------------|
| **URL** | Starting URL. Leave blank to continue from the previous block's page. |
-| **Engine** | AI engine: Skyvern 1.0 or Skyvern 2.0 |
+| **Engine** | AI engine. Skyvern 1.0 is the default for new browser blocks. |
| **Max Steps Override** | Cap the number of AI reasoning steps |
| **Disable Cache** | Skip cached script execution |
| **TOTP Identifier** | Link TOTP credentials for 2FA handling |
@@ -69,23 +69,23 @@ Browser-based blocks (Browser Task, Browser Action, Extraction, Login, File Down
The primary block for browser automation. Accepts a natural-language prompt and autonomously navigates the browser to accomplish the goal.
-The block has two engine modes, selected via the **Engine** dropdown. The fields shown change depending on which engine you choose.
+The block uses Skyvern 1.0 by default. Existing workflows that already contain V2 browser blocks remain editable and may show a reduced field set.
-**Skyvern 2.0** (recommended):
+**Skyvern 1.0:**
| Field | Type | Description |
|-------|------|-------------|
| **URL** | text | Starting URL (optional) |
| **Prompt** | text | Natural language instructions for the AI |
-| **Max Steps** | number | Maximum AI steps |
-| **Disable Cache** | boolean | Skip cached script execution |
-**Skyvern 1.0:**
+**Existing V2 blocks:**
| Field | Type | Description |
|-------|------|-------------|
| **URL** | text | Starting URL (optional) |
| **Prompt** | text | Natural language instructions for the AI |
+| **Max Steps** | number | Maximum AI steps |
+| **Disable Cache** | boolean | Skip cached script execution |
Additional fields in **Advanced Settings** (Skyvern 1.0 only):
diff --git a/docs/cloud/getting-started/core-concepts.mdx b/docs/cloud/getting-started/core-concepts.mdx
index d9c02ddbb..e88937849 100644
--- a/docs/cloud/getting-started/core-concepts.mdx
+++ b/docs/cloud/getting-started/core-concepts.mdx
@@ -188,17 +188,17 @@ Use schedules for daily reports, hourly monitoring, periodic data syncs, or anyt
An **engine** is the AI model Skyvern uses to drive the browser. Different engines have different strengths — speed, accuracy on complex pages, cost — and you can pick one per task or per block.
-The engine picker appears on the Discover page (for tasks) and on every browser-driven block in the workflow editor.
+The engine picker appears in API/SDK task requests and on supported browser-driven blocks in the workflow editor.
| Engine | When to use |
|--------|-------------|
-| **Skyvern 2.0** | Default. Best balance of accuracy and speed for most automations. |
-| **Skyvern 1.0** | Lighter and faster for simple, single-page interactions. |
+| **Skyvern 1.0** | Default for new tasks. Lighter and faster for simple, single-page interactions. |
+| **Skyvern 2.0** | Available for existing V2 workflows and explicitly requested V2 task runs. |
| **OpenAI CUA** | OpenAI's Computer Use Agent. Good for visual reasoning. |
| **Anthropic CUA** | Anthropic's Claude Computer Use. Strong at multi-step planning. |
| **UI-TARS** | Lightweight CUA model option. |
-If you're not sure, leave it on the default. Switch engines if you hit accuracy issues on a specific site.
+If you're not sure, use the default. Move repeated automations into workflows when you need scheduling, reusable parameters, or cached code replays.
---
diff --git a/docs/cloud/getting-started/run-a-task.mdx b/docs/cloud/getting-started/run-a-task.mdx
index c13350d82..a6c45e58d 100644
--- a/docs/cloud/getting-started/run-a-task.mdx
+++ b/docs/cloud/getting-started/run-a-task.mdx
@@ -39,16 +39,16 @@ Below the prompt box, **quick-action buttons** offer pre-built examples like "Ad
## Choosing an engine
-The dropdown next to the send button controls which engine runs the task.
+New tasks created from the Discover page use the default Skyvern 1.0 task engine. For API and SDK calls, the `engine` parameter controls which engine runs the task.
| Engine | Best for |
|--------|----------|
-| **Skyvern 2.0 with Code** | Complex, multi-step tasks. Generates reusable scripts. **(Default)** |
-| **Skyvern 2.0** | Complex tasks without script generation |
-| **Skyvern 1.0** | Simple, single-objective tasks. Faster and cheaper. |
+| **Skyvern 1.0** | Default for new tasks. Simple, single-objective tasks. Faster and cheaper. |
+| **OpenAI CUA** | Computer-use tasks powered by OpenAI's CUA model |
+| **Anthropic CUA** | Computer-use tasks powered by Anthropic's Claude model |
<Tip>
-Start with the default. Switch to Skyvern 1.0 when you have a straightforward, single-page task and want faster execution.
+Start with the default. Move repeated automations into workflows when you need scheduling, reusable parameters, or cached code replays.
</Tip>
---
diff --git a/docs/cloud/getting-started/run-your-first-task.mdx b/docs/cloud/getting-started/run-your-first-task.mdx
index 1fd3ef98b..4644a580b 100644
--- a/docs/cloud/getting-started/run-your-first-task.mdx
+++ b/docs/cloud/getting-started/run-your-first-task.mdx
@@ -34,19 +34,9 @@ Below the input, you'll see quick-action chips like "Add a product to cart" and
The more specific your prompt, the better. "Get the title of the #1 post" works much better than "get some data." Include the exact fields you want, what success looks like, and any constraints.
</Tip>
-## Step 2: Pick an engine and run
+## Step 2: Create and run the workflow
-Next to your prompt, you'll see an engine selector. Click it to switch engines:
-
-| Engine | When to use it |
-|--------|---------------|
-| **Skyvern 1.0** | Tasks with a simple, single goal: filling a form, searching for information on Google, reading content from a page |
-| **Skyvern 2.0** | Complex, multi-step tasks. Scores state-of-the-art 85.85% on the WebVoyager benchmark |
-| **Skyvern 2.0 with Code** | The default engine. Same capabilities as Skyvern 2.0, plus auto-generates reusable code and a workflow from the run |
-
-For this example, keep the default **Skyvern 2.0 with Code** selected.
-
-Click the **send button** (arrow icon to the right of the input). Skyvern generates a workflow from your prompt and opens it in the workflow editor. Click **Run** in the top right, confirm the parameters, then click **Run workflow** to start execution.
+Click the **send button** (arrow icon to the right of the input). Skyvern generates a workflow from your prompt using the default Skyvern 1.0 task engine and opens it in the workflow editor. Click **Run** in the top right, confirm the parameters, then click **Run workflow** to start execution.
<Accordion title="Optional: Advanced settings">
Click the **gear icon** next to send to configure additional options before running:
@@ -116,7 +106,7 @@ Now that you've seen the basic flow, here are a few ideas to try next:
- **Fill a form**: Point Skyvern at a contact form and tell it what to enter in each field
- **Compare prices**: Extract product names and prices from an e-commerce page using a data schema
-- **Navigate a flow**: Use Skyvern 2.0 to walk through a multi-page checkout or signup process
+- **Navigate a flow**: Build a workflow to walk through a multi-page checkout or signup process
- **Use an Agent template**: Check the **Agents** section in the sidebar for pre-built automations you can run instantly
---
diff --git a/docs/cloud/viewing-results/run-details.mdx b/docs/cloud/viewing-results/run-details.mdx
index d8e4a459a..31a225b83 100644
--- a/docs/cloud/viewing-results/run-details.mdx
+++ b/docs/cloud/viewing-results/run-details.mdx
@@ -79,7 +79,7 @@ If the run was canceled before the browser started, you'll see a "No recording a
### Code
-Python code generated from the run. This tab appears when code generation is enabled (the default engine). Copy the code to run outside Skyvern, or click **Copy & Explain** for an AI-generated explanation.
+Python code generated from the run. This tab appears when code generation is enabled. Copy the code to run outside Skyvern, or click **Copy & Explain** for an AI-generated explanation.
<img src="/images/cloud/workflow-run-code-tab.png" alt="Code tab showing generated Python code with syntax highlighting" />
diff --git a/docs/developers/browser-automations/actions-reference.mdx b/docs/developers/browser-automations/actions-reference.mdx
index 2a9b74e06..611504e46 100644
--- a/docs/developers/browser-automations/actions-reference.mdx
+++ b/docs/developers/browser-automations/actions-reference.mdx
@@ -552,7 +552,7 @@ console.log(result.output)
| `prompt` | `str` | Yes | Multi-step goal description |
| `data_extraction_schema` | `dict \| str` | No | JSON Schema for structured output. See [Extract Structured Data](/developers/browser-automations/extract-structured-data). |
| `max_steps` | `int` | No | Cap AI steps. The run terminates with `timed_out` if hit. Controls cost; each step is one AI decision + action cycle. |
-| `engine` | `RunEngine` | No | AI engine. Defaults to `skyvern-1.0` in the SDK for backward compatibility. Pass `skyvern-2.0` for the latest model (also the Cloud UI default). Other options: `openai-cua`, `anthropic-cua`, `ui-tars`. |
+| `engine` | `RunEngine` | No | AI engine. Defaults to `skyvern-1.0` in the SDK and Cloud UI. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. Other options: `openai-cua`, `anthropic-cua`, `ui-tars`. |
| `model` | `dict` / `Record<string, unknown>` | No | Override LLM model configuration |
| `url` | `str` / `string` | No | URL to navigate to (defaults to current page URL) |
| `webhook_url` | `str` / `string` | No | Callback URL. Skyvern POSTs the full run result on completion or failure. See [Webhooks](/developers/going-to-production/webhooks). |
diff --git a/docs/developers/features/code-caching.mdx b/docs/developers/features/code-caching.mdx
index ead279be9..5a1a07501 100644
--- a/docs/developers/features/code-caching.mdx
+++ b/docs/developers/features/code-caching.mdx
@@ -8,7 +8,7 @@ keywords:
- code caching
- code generation
- run_with
- - Skyvern 2.0 with Code
+ - cached code
- deterministic runs
- script generation
- cost optimization
@@ -19,14 +19,14 @@ When Skyvern's agent completes a task or workflow, it records the actions it too
## How it works
-The first run uses the agent as normal. Set `engine="skyvern-2.0"` when creating the task or workflow, and Skyvern records the actions as generated code while the agent executes.
+The first run uses the agent as normal. Create a workflow and run it with `run_with="agent"` so Skyvern can record the successful browser actions as generated code.
On subsequent runs, pass `run_with="code"` to execute the cached code directly. No screenshots, no LLM reasoning, just the recorded action sequence replaying against the page.
If the cached code hits something unexpected (a layout change, a new field, a missing element), Skyvern re-runs with the full agent and regenerates the cache. You don't need to handle this yourself.
<Note>
-The SDK default engine is `skyvern-1.0`. To use code caching, explicitly set `engine="skyvern-2.0"`. In the Cloud UI, `skyvern-2.0` is the default.
+The SDK and Cloud UI default to `skyvern-1.0` for new task creation. Use workflows plus `run_with="code"` for cached replays.
</Note>
## What gets cached
diff --git a/docs/developers/optimization/cost-control.mdx b/docs/developers/optimization/cost-control.mdx
index 26432ec98..c3b447902 100644
--- a/docs/developers/optimization/cost-control.mdx
+++ b/docs/developers/optimization/cost-control.mdx
@@ -123,11 +123,11 @@ If runs consistently time out, increase `max_steps` or simplify the task. If `st
---
-## Use code generation for repeatable tasks
+## Use code generation for repeatable workflows
-On Skyvern Cloud, the default **Skyvern 2.0 with Code** engine records the actions the AI takes and generates reusable code from them. Subsequent runs execute the generated code instead of the AI agent, skipping LLM inference and screenshot analysis entirely. This makes them faster, deterministic, and significantly cheaper.
+On Skyvern Cloud, successful workflow runs can record the actions the AI takes and generate reusable code from them. Subsequent runs execute the generated code instead of the AI agent, skipping LLM inference and screenshot analysis entirely. This makes them faster, deterministic, and significantly cheaper.
-1. Run your task with the default engine. Skyvern generates code from the recorded actions.
+1. Run your workflow with the agent. Skyvern generates code from the recorded actions.
2. Subsequent runs execute the cached code directly, no AI reasoning required.
3. If the code doesn't handle an edge case, adjust your prompt and re-run to regenerate. Skyvern also falls back to the AI agent automatically if the cached code fails.
@@ -203,7 +203,7 @@ curl -X POST "https://api.skyvern.com/v1/run/tasks" \
</CodeGroup>
<Tip>
-Set `publish_workflow: true` to save the generated workflow so you can re-trigger it later or [schedule it on a recurring cron](/cloud/building-workflows/scheduling).
+Create a workflow when you need to re-trigger the automation later or [schedule it on a recurring cron](/cloud/building-workflows/scheduling).
</Tip>
---
@@ -214,8 +214,8 @@ Not every task needs the most powerful engine. Use a lighter engine for simple,
| Engine | Cost | Best for |
|--------|------|----------|
-| `skyvern-2.0` | Highest | Complex, multi-step tasks that require flexibility |
| `skyvern-1.0` | Lower | Single-objective tasks like form fills or single-page extraction |
+| `skyvern-2.0` | Highest | Existing V2 workflows or explicitly requested V2 task runs |
<CodeGroup>
```python Python
diff --git a/docs/integrations/make.mdx b/docs/integrations/make.mdx
index 11bc120b2..8bb498d5a 100644
--- a/docs/integrations/make.mdx
+++ b/docs/integrations/make.mdx
@@ -17,7 +17,7 @@ Connect Skyvern to 2,000+ apps through Make. Trigger browser automations from an
## Available Modules
- **Run a Task**: Run an automation using **Skyvern 1.0** (simple, single-step goals)
-- **Run a Task V2**: Run an automation using **Skyvern 2.0** (complex, multi-step goals)
+- **Run a Task V2**: Legacy module for explicitly requested V2 task runs
- **Run a Workflow**: Run a pre-built Skyvern workflow with parameters
- **Get a Task / Get a Task V2**: Retrieve results from a previously run task
- **Get a Workflow**: Retrieve results from a previously run workflow
diff --git a/docs/integrations/n8n.mdx b/docs/integrations/n8n.mdx
index f3a53440f..08544cafa 100644
--- a/docs/integrations/n8n.mdx
+++ b/docs/integrations/n8n.mdx
@@ -66,9 +66,9 @@ Connect Skyvern to n8n's open-source automation platform. Trigger browser automa
Under **Task Options**:
-- **Engine**: Defaults to **Skyvern 2.0**.
+- **Engine**: Defaults to **Skyvern 1.0**.
- **Skyvern 1.0**: Simple, single-step tasks
- - **Skyvern 2.0**: Complex, multi-step goals with dynamic planning
+ - **Skyvern 2.0**: Existing V2 workflows or explicitly requested V2 task runs
- **OpenAI CUA** / **Anthropic CUA**: Third-party computer-use agents
### Dispatch a Workflow Run
diff --git a/docs/integrations/workato.mdx b/docs/integrations/workato.mdx
index 2a0206290..690252ba9 100644
--- a/docs/integrations/workato.mdx
+++ b/docs/integrations/workato.mdx
@@ -16,7 +16,7 @@ Connect Skyvern to Workato's enterprise automation platform. Trigger browser aut
## Available Actions
- **Create and Run Task**: Run an automation using **Skyvern 1.0** (simple, single-step goals)
-- **Create and Run Task V2**: Run an automation using **Skyvern 2.0** (complex, multi-step goals)
+- **Create and Run Task V2**: Legacy action for explicitly requested V2 task runs
- **Run a Workflow**: Run a pre-built Skyvern workflow with parameters
- **Get Task / Get Task V2**: Retrieve results from a previously run task
- **Get Workflow**: Retrieve results from a previously run workflow
diff --git a/docs/integrations/zapier.mdx b/docs/integrations/zapier.mdx
index c127bc327..c1f76a660 100644
--- a/docs/integrations/zapier.mdx
+++ b/docs/integrations/zapier.mdx
@@ -22,7 +22,7 @@ Connect Skyvern to 7,000+ apps through Zapier. Trigger browser automations from
## Available Actions
- **Create and Run a Task**: Run an automation using **Skyvern 1.0** (simple, single-step goals)
-- **Create and Run Task V2**: Run an automation using **Skyvern 2.0** (complex, multi-step goals)
+- **Create and Run Task V2**: Legacy action for explicitly requested V2 task runs
- **Run a Workflow**: Run a pre-built Skyvern workflow with parameters
- **Get a Task / Get a Task V2**: Retrieve results from a previously run task
- **Get a Workflow**: Retrieve results from a previously run workflow
diff --git a/docs/sdk-reference/complete-reference.mdx b/docs/sdk-reference/complete-reference.mdx
index 02e6cea4e..80cd0ef8f 100644
--- a/docs/sdk-reference/complete-reference.mdx
+++ b/docs/sdk-reference/complete-reference.mdx
@@ -292,7 +292,7 @@ const result = await page.agent.runWorkflow("wpid_abc123", {
result = await client.run_task(
prompt: str, # Required
url: str | None = None,
- engine: RunEngine = RunEngine.skyvern_v2,
+ engine: RunEngine = RunEngine.skyvern_v1,
wait_for_completion: bool = False,
timeout: float = 1800,
max_steps: int | None = None,
@@ -320,7 +320,7 @@ const result = await skyvern.runTask({
body: {
prompt: string, // Required
url?: string,
- engine?: RunEngine, // "skyvern_v2" default
+ engine?: RunEngine, // "skyvern-1.0" default
max_steps?: number,
data_extraction_schema?: Record<string, unknown> | string,
browser_session_id?: string,
@@ -693,6 +693,7 @@ request_options=RequestOptions(
- `browser_profile_id` works with `run_workflow` only - silently ignored by `run_task`.
- Python `download_files` does not support `wait_for_completion` - poll manually or use webhooks.
+- `publish_workflow=True` is deprecated and routes through the legacy Skyvern 2.0 publish path for backwards compatibility. Prefer creating reusable workflows with the workflow APIs.
- Only workflow runs with `persist_browser_session=True` produce archives for profile creation.
- `engine` accepts `RunEngine` enum values: `skyvern_v1`, `skyvern_v2`, `openai_cua`, `anthropic_cua`, `ui_tars`, `yutori_navigator`.
- `launch_local_browser` requires Python local mode (`Skyvern.local()`) and the `skyvern[local]` extra.
diff --git a/docs/sdk-reference/tasks/run-task.mdx b/docs/sdk-reference/tasks/run-task.mdx
index f349aef53..683b4713a 100644
--- a/docs/sdk-reference/tasks/run-task.mdx
+++ b/docs/sdk-reference/tasks/run-task.mdx
@@ -43,14 +43,14 @@ console.log(result.output);
|-----------|------|----------|---------|-------------|
| `prompt` | `str` | Yes | - | Natural language instructions for what the AI should do. |
| `url` | `str` | No | `None` | Starting page URL. If omitted, the AI navigates from a blank page. |
-| `engine` | `RunEngine` | No | `skyvern_v2` | AI engine. Options: `skyvern_v2`, `skyvern_v1`, `openai_cua`, `anthropic_cua`, `ui_tars`. |
+| `engine` | `RunEngine` | No | `skyvern_v1` / `"skyvern-1.0"` | AI engine. Python enum options: `skyvern_v1`, `skyvern_v2`, `openai_cua`, `anthropic_cua`, `ui_tars`. TypeScript uses the wire values: `"skyvern-1.0"`, `"skyvern-2.0"`, `"openai-cua"`, `"anthropic-cua"`, `"ui-tars"`. |
| `wait_for_completion` | `bool` | No | `False` | Block until the run finishes. |
| `timeout` | `float` | No | `1800` | Max wait time in seconds when `wait_for_completion=True`. |
| `max_steps` | `int` | No | `None` | Cap the number of AI steps to limit cost. Run terminates with `timed_out` if hit. |
| `data_extraction_schema` | `dict \| str` | No | `None` | JSON schema or Pydantic model name constraining the output shape. |
| `proxy_location` | `ProxyLocation` | No | `None` | Route the browser through a geographic proxy. |
| `browser_session_id` | `str` | No | `None` | Run inside an existing [browser session](/developers/optimization/browser-sessions). |
-| `publish_workflow` | `bool` | No | `False` | Save the generated code as a reusable workflow. Only works with `skyvern_v2`. |
+| `publish_workflow` | `bool` | No | `False` | Deprecated. Routes the request through the legacy Skyvern 2.0 publish path for backwards compatibility; prefer creating workflows with the workflow APIs. |
| `webhook_url` | `str` | No | `None` | URL to receive a POST when the run finishes. |
| `error_code_mapping` | `dict[str, str]` | No | `None` | Map custom error codes to failure reasons. |
| `totp_identifier` | `str` | No | `None` | Identifier for TOTP verification. |
@@ -184,7 +184,7 @@ const result = await skyvern.runTask({
```
</CodeGroup>
-**Use a lighter engine:**
+**Set an engine explicitly:**
<CodeGroup>
```python Python
@@ -203,14 +203,14 @@ const result = await skyvern.runTask({
body: {
prompt: "Get the page title",
url: "https://example.com",
- engine: "skyvern_v1",
+ engine: "skyvern-1.0",
},
waitForCompletion: true,
});
```
</CodeGroup>
-**Publish as a reusable workflow:**
+**Legacy: publish a V2 task as a reusable workflow:**
<CodeGroup>
```python Python
diff --git a/docs/snippets/core-concepts-content.mdx b/docs/snippets/core-concepts-content.mdx
index c9d1b7738..52d4c0abb 100644
--- a/docs/snippets/core-concepts-content.mdx
+++ b/docs/snippets/core-concepts-content.mdx
@@ -298,7 +298,7 @@ In the Skyvern UI, go to **Runs**, click a run, and view the **Actions** and **R
## Engines
-Skyvern supports multiple AI engines. `skyvern-2.0` is the latest and default for the Cloud UI (the SDK defaults to `skyvern-1.0`). Other options include `openai-cua` (OpenAI Computer Use Agent), `anthropic-cua` (Anthropic Computer Use Agent), and `ui-tars`.
+Skyvern supports multiple AI engines. `skyvern-1.0` is the default for the Cloud UI and SDK. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. Other options include `openai-cua` (OpenAI Computer Use Agent), `anthropic-cua` (Anthropic Computer Use Agent), and `ui-tars`.
```python
from skyvern.schemas.runs import RunEngine
@@ -306,7 +306,7 @@ from skyvern.schemas.runs import RunEngine
result = await skyvern.run_task(
prompt="Extract pricing data",
url="https://example.com",
- engine=RunEngine.skyvern_v2
+ engine=RunEngine.skyvern_v1
)
```
diff --git a/docs/snippets/introduction-content.mdx b/docs/snippets/introduction-content.mdx
index 8d3503646..14231ebb6 100644
--- a/docs/snippets/introduction-content.mdx
+++ b/docs/snippets/introduction-content.mdx
@@ -20,11 +20,11 @@ Each cycle through this loop is called a **step**. Understanding what happens in
A typical task takes 2 to 10 steps. You can set `max_steps` to cap cost during development.
-### The Planner-Agent-Validator system
+### Existing V2 Planner-Agent-Validator system
-For anything beyond simple single-page tasks, Skyvern 2.0 wraps the agent loop in a higher-level system with three components:
+Existing V2 workflows may use a higher-level system with three components:
-<img src="/images/skyvern-explainer.png" alt="Skyvern 2.0 architecture: Planner breaks prompt into sub-tasks, Task Agent executes them, Validator confirms completion" />
+<img src="/images/skyvern-explainer.png" alt="V2 architecture: Planner breaks prompt into sub-tasks, Task Agent executes them, Validator confirms completion" />
The **Planner** takes your prompt and breaks it into an ordered sequence of sub-tasks. If you say "log into the vendor portal, download all invoices from January, and save them as PDFs," the Planner sequences that into: navigate to login → authenticate → find the invoice section → loop through January invoices → download each one.
diff --git a/fern/openapi/skyvern_openapi.json b/fern/openapi/skyvern_openapi.json
index 33b0080c5..0a401bc2e 100644
--- a/fern/openapi/skyvern_openapi.json
+++ b/fern/openapi/skyvern_openapi.json
@@ -16835,7 +16835,7 @@
},
"engine": {
"$ref": "#/components/schemas/RunEngine",
- "description": "\nThe engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.\n",
+ "description": "\nThe engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.\n",
"default": "skyvern-1.0"
},
"title": {
@@ -17025,7 +17025,8 @@
"publish_workflow": {
"type": "boolean",
"title": "Publish Workflow",
- "description": "Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.",
+ "description": "Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.",
+ "deprecated": true,
"default": false
},
"include_action_history_in_verification": {
diff --git a/fern/running-tasks/api-spec.mdx b/fern/running-tasks/api-spec.mdx
index 9c6e68ff0..7032970dd 100644
--- a/fern/running-tasks/api-spec.mdx
+++ b/fern/running-tasks/api-spec.mdx
@@ -28,7 +28,7 @@ Production: `https://api.skyvern.com/v1/run/tasks`
| prompt | String | yes | "Apply for a job" | The goal or task description for Skyvern to accomplish |
| url | String | no | https://www.example.com | The starting URL for the task. If not provided, Skyvern will attempt to determine an appropriate URL |
| title | String | no | "Job Application Task" | Optional title for the task |
-| engine | String | no | "skyvern-2.0" | The Skyvern engine version to use for this task. Supported values are "skyvern-1.0" and "skyvern-2.0". Default is "skyvern-2.0" |
+| engine | String | no | "skyvern-1.0" | The Skyvern engine version to use for this task. Supported values are "skyvern-1.0" and "skyvern-2.0". Default is "skyvern-1.0" |
| proxy_location | String | no | "RESIDENTIAL" | Geographic Proxy location to route the browser traffic through. Default is "RESIDENTIAL" |
| data_extraction_schema | Object | no | \{ "success": \{ "type": "boolean" } } | Schema defining what data should be extracted from the webpage |
| error_code_mapping | Object | no | \{ "AUTH_FAILED": "Authentication failed" } | Custom mapping of error codes to error messages if Skyvern encounters an error |
@@ -37,7 +37,7 @@ Production: `https://api.skyvern.com/v1/run/tasks`
| totp_identifier | String | no | "[email protected]" | Identifier for TOTP (Time-based One-Time Password) authentication if codes are being pushed to Skyvern |
| totp_url | String | no | https://api.example.com/totp | URL for TOTP authentication setup if Skyvern should be polling endpoint for 2FA codes |
| browser_session_id | String | no | "sess_123" | ID of an existing browser session to reuse, having it continue from the current screen state |
-| publish_workflow | Boolean | no | false | Whether to publish this task as a reusable workflow. Default is false |
+| publish_workflow | Boolean | no | false | Deprecated. Publish an explicitly requested V2 task as a reusable workflow. Default is false |
## Example Request (Apply for a job)
@@ -48,7 +48,7 @@ POST https://api.skyvern.com/v1/run/tasks
"prompt": "Apply for a job on behalf of this person: name: Chris P Bacon. email: [email protected]",
"url": "https://jobs.lever.co/leverdemo-8/45d39614-464a-4b62-a5cd-8683ce4fb80a/apply",
"title": "Job Application Task",
- "engine": "skyvern-2.0",
+ "engine": "skyvern-1.0",
"proxy_location": "RESIDENTIAL",
"data_extraction_schema": {
"application_success": {
@@ -113,7 +113,7 @@ The response follows the same schema as the task creation response, containing:
| created_at | String | "2025-04-03T14:08:29.505Z" | Timestamp when this run was created |
| modified_at | String | "2025-04-03T14:08:29.505Z" | Timestamp when this run was last modified |
| run_type | String | "task_v1" | Type of task run - either task_v1 or task_v2 |
-| run_request | Object | \{ "prompt": "string", "url": "string", "title": "string", "engine": "skyvern-2.0", "proxy_location": "RESIDENTIAL", "data_extraction_schema": \{ "additionalProp1": \{ } \}, "error_code_mapping": \{ "additionalProp1": "string" \}, "max_steps": 0, "webhook_url": "string", "totp_identifier": "string", "totp_url": "string", "browser_session_id": "string", "publish_workflow": false } | The original request parameters used to start this task run |
+| run_request | Object | \{ "prompt": "string", "url": "string", "title": "string", "engine": "skyvern-1.0", "proxy_location": "RESIDENTIAL", "data_extraction_schema": \{ "additionalProp1": \{ } \}, "error_code_mapping": \{ "additionalProp1": "string" \}, "max_steps": 0, "webhook_url": "string", "totp_identifier": "string", "totp_url": "string", "browser_session_id": "string", "publish_workflow": false } | The original request parameters used to start this task run |
## Request - List Steps (GET)
Each task run is made up of "steps" which are the individual actions Skyvern takes to complete the task. You can use this endpoint to get all the steps of the run.
diff --git a/fern/running-tasks/run-tasks.mdx b/fern/running-tasks/run-tasks.mdx
index 3f3833437..f2ec2c9dd 100644
--- a/fern/running-tasks/run-tasks.mdx
+++ b/fern/running-tasks/run-tasks.mdx
@@ -20,8 +20,8 @@ Parameter: `engine`
This parameter defines the engine that powers the agent task.
-- `skyvern-2.0`: this is the default engine. It's the latest Skyvern agent that performs really well with complex and multi-step tasks. It scores **state of the art** 85.85% on the [WebVoyager benchmark](https://www.skyvern.com/blog/skyvern-2-0-state-of-the-art-web-navigation-with-85-8-on-webvoyager-eval/).
-- `skyvern-1.0`: performs really well for tasks with a simple goal, like filling a form, or searching for information on Google.
+- `skyvern-1.0`: the default engine. Performs well for tasks with a simple goal, like filling a form, or searching for information on Google.
+- `skyvern-2.0`: remains available for existing V2 workflows and explicitly requested V2 task runs.
- `openai-cua`: uses OpenAI's CUA model.
- `anthropic-cua`: uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
- `ui-tars`: uses the UI-TARS model (Seed1.5-VL) via Doubao API for computer vision and GUI automation with multi-turn conversation support (https://seed.bytedance.com/zh/tech/seed1_5_vl).
@@ -180,4 +180,4 @@ task = await skyvern.run_task(
webhook_url="https://your-webhook-url.com",
)
```
-You can also use the [GET RUN API](/api-reference/api-reference/agent/get-run) to get the current status of the task.
\ No newline at end of file
+You can also use the [GET RUN API](/api-reference/api-reference/agent/get-run) to get the current status of the task.
diff --git a/fern/workflows/introduction.mdx b/fern/workflows/introduction.mdx
index 4e748ff0a..029a05f3b 100644
--- a/fern/workflows/introduction.mdx
+++ b/fern/workflows/introduction.mdx
@@ -23,4 +23,4 @@ Building blocks supported today:
- PDFParserBlock: Given a pdf url, Skyvern downloads the PDF file from the url and returns the parsed content as the output of the block.
- FileUploadBlock: Upload all the downloaded files to a desired destination. Currently only AWS S3 is supported. Please contact [email protected] if you need more integrations.
- WaitBlock: Wait for a given amount of time.
-- NavigationV2Block (TaskV2Block): The advanced version of the NavigationBlock, powered by the Skyvern 2.0 engine. Designed for complicated goals.
\ No newline at end of file
+- NavigationV2Block (TaskV2Block): Legacy V2 navigation block. Existing workflows that contain this block remain supported.
diff --git a/fern/workflows/workflow-blocks-details.mdx b/fern/workflows/workflow-blocks-details.mdx
index b5cbc0a08..89320bc1d 100644
--- a/fern/workflows/workflow-blocks-details.mdx
+++ b/fern/workflows/workflow-blocks-details.mdx
@@ -55,4 +55,4 @@ This block uploads all the downloaded files to a desired destination. Currently
This block waits for a given amount of time.
## NavigationV2Block (TaskV2Block)
-The advanced version of the NavigationBlock, powered by the Skyvern 2.0 engine. Designed for complicated goals.
\ No newline at end of file
+Legacy V2 navigation block. Existing workflows that contain this block remain supported.
diff --git a/skyvern-frontend/src/components/EngineSelector.tsx b/skyvern-frontend/src/components/EngineSelector.tsx
index 4a659a9a6..180e2352b 100644
--- a/skyvern-frontend/src/components/EngineSelector.tsx
+++ b/skyvern-frontend/src/components/EngineSelector.tsx
@@ -32,8 +32,8 @@ const allEngineOptions: Array<EngineOption> = [
{
value: RunEngine.SkyvernV2,
label: "Skyvern 2.0",
- badge: "Multi-Goal",
- badgeVariant: "warning",
+ badge: "Legacy",
+ badgeVariant: "default",
},
{
value: RunEngine.OpenaiCua,
diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx
new file mode 100644
index 000000000..f60035a1e
--- /dev/null
+++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.test.tsx
@@ -0,0 +1,201 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
+import type {
+ ButtonHTMLAttributes,
+ InputHTMLAttributes,
+ ReactNode,
+ TextareaHTMLAttributes,
+} from "react";
+import { afterEach, describe, expect, test, vi } from "vitest";
+
+import { PromptBox } from "./PromptBox";
+
+const { mockNavigate, mockPost, mockSetAutoplay } = vi.hoisted(() => ({
+ mockNavigate: vi.fn(),
+ mockPost: vi.fn(),
+ mockSetAutoplay: vi.fn(),
+}));
+
+vi.mock("@/api/AxiosClient", () => ({
+ getClient: async () => ({
+ post: mockPost,
+ }),
+}));
+
+vi.mock("@/hooks/useCredentialGetter", () => ({
+ useCredentialGetter: () => undefined,
+}));
+
+vi.mock("@/store/useAutoplayStore", () => ({
+ useAutoplayStore: () => ({
+ setAutoplay: mockSetAutoplay,
+ }),
+}));
+
+vi.mock("react-router-dom", async () => {
+ const actual =
+ await vi.importActual<typeof import("react-router-dom")>(
+ "react-router-dom",
+ );
+ return {
+ ...actual,
+ useNavigate: () => mockNavigate,
+ };
+});
+
+vi.mock("@/components/AutoResizingTextarea/AutoResizingTextarea", () => ({
+ AutoResizingTextarea: (
+ props: TextareaHTMLAttributes<HTMLTextAreaElement>,
+ ) => <textarea {...props} />,
+}));
+
+vi.mock("@/components/ui/button", () => ({
+ Button: ({ children, ...props }: ButtonHTMLAttributes<HTMLButtonElement>) => (
+ <button {...props}>{children}</button>
+ ),
+}));
+
+vi.mock("@/components/ui/input", () => ({
+ Input: (props: InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
+}));
+
+vi.mock("@/components/ui/switch", () => ({
+ Switch: () => null,
+}));
+
+vi.mock("@/components/ui/use-toast", () => ({
+ toast: vi.fn(),
+}));
+
+vi.mock("@/components/ProxySelector", () => ({
+ ProxySelector: () => null,
+}));
+
+vi.mock("@/components/KeyValueInput", () => ({
+ KeyValueInput: () => null,
+}));
+
+vi.mock("@/routes/workflows/components/CodeEditor", () => ({
+ CodeEditor: () => null,
+}));
+
+vi.mock("@/components/TestWebhookDialog", () => ({
+ TestWebhookDialog: ({ trigger }: { trigger: ReactNode }) => <>{trigger}</>,
+}));
+
+vi.mock("@/components/ImprovePrompt", () => ({
+ ImprovePrompt: () => null,
+}));
+
+vi.mock("./ExampleCasePill", () => ({
+ ExampleCasePill: ({
+ label,
+ onClick,
+ }: {
+ label: string;
+ onClick: () => void;
+ }) => (
+ <button type="button" onClick={onClick}>
+ {label}
+ </button>
+ ),
+}));
+
+vi.mock("@radix-ui/react-icons", () => ({
+ FileTextIcon: () => null,
+ GearIcon: () => null,
+ Pencil1Icon: () => null,
+ ReloadIcon: () => null,
+ PaperPlaneIcon: (props: ButtonHTMLAttributes<HTMLButtonElement>) => (
+ <button type="button" aria-label="submit-prompt" {...props} />
+ ),
+}));
+
+vi.mock("@/components/icons/CartIcon", () => ({ CartIcon: () => null }));
+vi.mock("@/components/icons/GraphIcon", () => ({ GraphIcon: () => null }));
+vi.mock("@/components/icons/InboxIcon", () => ({ InboxIcon: () => null }));
+vi.mock("@/components/icons/MessageIcon", () => ({ MessageIcon: () => null }));
+vi.mock("@/components/icons/TrophyIcon", () => ({ TrophyIcon: () => null }));
+
+function renderPromptBox(enableCopilotHandoff = false) {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
+ });
+
+ return render(
+ <QueryClientProvider client={queryClient}>
+ <PromptBox enableCopilotHandoff={enableCopilotHandoff} />
+ </QueryClientProvider>,
+ );
+}
+
+afterEach(() => {
+ cleanup();
+ mockNavigate.mockReset();
+ mockPost.mockReset();
+ mockSetAutoplay.mockReset();
+});
+
+describe("PromptBox", () => {
+ test("creates prompt-generated workflows as V1 agent runs", async () => {
+ mockPost.mockResolvedValue({
+ data: {
+ workflow_permanent_id: "wpid_1",
+ workflow_definition: { blocks: [] },
+ },
+ });
+
+ renderPromptBox();
+
+ expect(screen.queryByText("Skyvern 2.0")).toBeNull();
+
+ fireEvent.change(screen.getByPlaceholderText("Enter your prompt..."), {
+ target: { value: "Visit the docs" },
+ });
+ fireEvent.click(screen.getByLabelText("submit-prompt"));
+
+ await waitFor(() => expect(mockPost).toHaveBeenCalledTimes(1));
+ const call = mockPost.mock.calls[0];
+ expect(call).toBeDefined();
+ const [path, body] = call!;
+
+ expect(path).toBe("/workflows/create-from-prompt");
+ expect(body.task_version).toBe("v1");
+ expect(body.request.run_with).toBe("agent");
+ expect(body.request.url).toBe("https://google.com");
+ });
+
+ test("hands Discover prompts to workflow copilot with agent execution", async () => {
+ mockPost.mockResolvedValue({
+ data: {
+ workflow_permanent_id: "wpid_copilot",
+ workflow_definition: { blocks: [] },
+ },
+ });
+
+ renderPromptBox(true);
+
+ fireEvent.change(screen.getByPlaceholderText("Enter your prompt..."), {
+ target: { value: "Build this workflow" },
+ });
+ fireEvent.click(screen.getByLabelText("submit-prompt"));
+
+ await waitFor(() => expect(mockPost).toHaveBeenCalledTimes(1));
+ const call = mockPost.mock.calls[0];
+ expect(call).toBeDefined();
+ const [path, yaml] = call!;
+
+ expect(path).toBe("/workflows");
+ expect(yaml).toContain("run_with: agent");
+ expect(yaml).not.toContain("run_with: code");
+ expect(mockNavigate).toHaveBeenCalledWith("/workflows/wpid_copilot/build", {
+ state: { copilotMessage: "Build this workflow" },
+ });
+ });
+});
diff --git a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx
index f72fa6002..c77288b2f 100644
--- a/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx
+++ b/skyvern-frontend/src/routes/tasks/create/PromptBox.tsx
@@ -13,14 +13,6 @@ import { ProxySelector } from "@/components/ProxySelector";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { KeyValueInput } from "@/components/KeyValueInput";
-import {
- CustomSelectItem,
- Select,
- SelectContent,
- SelectItemText,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { toast } from "@/components/ui/use-toast";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
@@ -32,7 +24,6 @@ import {
PaperPlaneIcon,
Pencil1Icon,
ReloadIcon,
- LightningBoltIcon,
} from "@radix-ui/react-icons";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios";
@@ -126,12 +117,6 @@ function deriveHandoffTitle(prompt: string): string {
return `${collapsed.slice(0, HANDOFF_TITLE_MAX_LEN - 1).trimEnd()}…`;
}
-function runWithFromSelector(
- legacyVersion: "v1" | "v2" | "v2-code",
-): "agent" | "code" {
- return legacyVersion === "v2-code" ? "code" : "agent";
-}
-
function buildBlankWorkflowRequest(
title: string,
runWith: "agent" | "code" = "agent",
@@ -153,7 +138,6 @@ function buildBlankWorkflowRequest(
function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
const navigate = useNavigate();
const [prompt, setPrompt] = useState<string>("");
- const [selectValue, setSelectValue] = useState<"v1" | "v2" | "v2-code">("v2"); // v2 (agent) is the default
const credentialGetter = useCredentialGetter();
const queryClient = useQueryClient();
const [webhookCallbackUrl, setWebhookCallbackUrl] = useState<string | null>(
@@ -181,16 +165,8 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
const submitInFlightRef = useRef(false);
const generateWorkflowMutation = useMutation({
- mutationFn: async ({
- prompt,
- version,
- }: {
- prompt: string;
- version: string;
- }) => {
+ mutationFn: async ({ prompt }: { prompt: string }) => {
const client = await getClient(credentialGetter, "sans-api-v1");
- const v = version === "v1" ? "v1" : "v2";
-
const request: Record<string, unknown> = {
user_prompt: prompt,
webhook_callback_url: webhookCallbackUrl,
@@ -198,7 +174,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
totp_identifier: totpIdentifier,
max_screenshot_scrolls: maxScreenshotScrolls,
publish_workflow: publishWorkflow,
- run_with: version === "v2-code" ? "code" : "agent",
+ run_with: "agent",
ai_fallback: true,
extracted_information_schema: dataSchema
? (() => {
@@ -220,9 +196,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
: null,
};
- if (v === "v1") {
- request.url = "https://google.com"; // a stand-in value; real url is generated via prompt
- }
+ request.url = "https://google.com"; // a stand-in value; real url is generated via prompt
const result = await client.post<
Createv2TaskRequest,
@@ -230,7 +204,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
>(
"/workflows/create-from-prompt",
{
- task_version: v,
+ task_version: "v1",
request,
},
{
@@ -318,23 +292,16 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
const isSubmitting =
generateWorkflowMutation.isPending || handoffWorkflowMutation.isPending;
- const submitPrompt = ({
- prompt,
- legacyVersion,
- }: {
- prompt: string;
- legacyVersion: "v1" | "v2" | "v2-code";
- }) => {
+ const submitPrompt = ({ prompt }: { prompt: string }) => {
if (submitInFlightRef.current || isSubmitting) {
return;
}
submitInFlightRef.current = true;
- const runWith = runWithFromSelector(legacyVersion);
if (enableCopilotHandoff) {
- handoffWorkflowMutation.mutate({ prompt, runWith });
+ handoffWorkflowMutation.mutate({ prompt, runWith: "agent" });
return;
}
- generateWorkflowMutation.mutate({ prompt, version: legacyVersion });
+ generateWorkflowMutation.mutate({ prompt });
};
return (
@@ -364,71 +331,6 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
onChange={(e) => setPrompt(e.target.value)}
placeholder="Enter your prompt..."
/>
- <Select
- value={selectValue}
- onValueChange={(value: "v1" | "v2" | "v2-code") => {
- setSelectValue(value);
- }}
- >
- <SelectTrigger className="w-48 focus:ring-0">
- {selectValue === "v2-code" ? (
- <div className="relative z-10 flex w-full flex-col items-center">
- <div className="flex items-center gap-1">
- <LightningBoltIcon className="size-4 shrink-0 text-yellow-400" />
- <div className="font-normal text-white">
- Skyvern 2.0
- </div>
- </div>
- <div className="self-start pl-7 text-xs font-semibold text-yellow-400">
- with code
- </div>
- </div>
- ) : (
- <SelectValue className="relative z-10" />
- )}
- </SelectTrigger>
- <SelectContent className="border-slate-500 bg-slate-elevation3">
- <CustomSelectItem value="v1">
- <div className="space-y-2">
- <div>
- <SelectItemText>Skyvern 1.0</SelectItemText>
- </div>
- <div className="text-xs text-slate-400">
- Best for simple tasks
- </div>
- </div>
- </CustomSelectItem>
- <CustomSelectItem value="v2" className="hover:bg-slate-800">
- <div className="space-y-2">
- <div>
- <SelectItemText>Skyvern 2.0</SelectItemText>
- </div>
- <div className="text-xs text-slate-400">
- Best for complex tasks
- </div>
- </div>
- </CustomSelectItem>
- <CustomSelectItem
- value="v2-code"
- className="relative overflow-hidden border-2 border-yellow-500/50 bg-gradient-to-r from-yellow-500/10 via-yellow-400/10 to-amber-400/10 hover:bg-slate-800"
- >
- <div className="animate-shimmer absolute inset-0 bg-gradient-to-r from-transparent via-yellow-400/20 to-transparent" />
- <div className="relative flex items-center gap-2 space-y-2">
- <div className="flex-1">
- <div className="flex items-center gap-2">
- <SelectItemText className="animate-pulse bg-gradient-to-r from-yellow-400 via-yellow-500 to-amber-400 bg-clip-text font-bold text-transparent">
- Skyvern 2.0
- </SelectItemText>
- <LightningBoltIcon className="size-4 animate-bounce text-yellow-400" />
- </div>
- <div className="bg-gradient-to-r from-yellow-400 via-yellow-500 to-amber-400 bg-clip-text text-xs font-semibold text-transparent">
- with code
- </div>
- </div>
- </div>
- </CustomSelectItem>
- </SelectContent>
- </Select>
<ImprovePrompt
isVisible={Boolean(prompt.trim())}
onBegin={() => {
@@ -463,7 +365,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
<PaperPlaneIcon
className="size-6 cursor-pointer"
onClick={() => {
- submitPrompt({ prompt, legacyVersion: selectValue });
+ submitPrompt({ prompt });
}}
/>
)}
@@ -680,10 +582,7 @@ function PromptBox({ enableCopilotHandoff = false }: PromptBoxProps) {
icon={example.icon}
label={example.label}
onClick={() => {
- submitPrompt({
- prompt: example.prompt,
- legacyVersion: "v2",
- });
+ submitPrompt({ prompt: example.prompt });
}}
/>
);
diff --git a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
index b33e55542..c285eb442 100644
--- a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
@@ -30,7 +30,7 @@ export const baseHelpTooltipContent = {
includeActionHistoryInVerification:
"Include the action history in the completion verification.",
engine:
- "Skyvern 1.0: Fast, single-goal tasks. Skyvern 2.0: Complex, multi-goal tasks (slower).",
+ "Skyvern 1.0 is the default for new browser tasks. Existing V2 blocks remain supported.",
} as const;
export const basePlaceholderContent = {
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.test.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.test.tsx
new file mode 100644
index 000000000..e70c07d4e
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.test.tsx
@@ -0,0 +1,168 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import type { ReactNode } from "react";
+import { afterEach, describe, expect, test, vi } from "vitest";
+
+import { RunEngine } from "@/api/types";
+
+import { NavigationEditor } from "./NavigationEditor";
+import { navigationNodeDefaultData, type NavigationNodeData } from "./types";
+
+let nodeData: { type: "navigation"; data: NavigationNodeData } | null = null;
+
+vi.mock("@xyflow/react", () => ({
+ useNodesData: () => nodeData,
+ useNodes: () => [],
+ useEdges: () => [],
+}));
+
+vi.mock("@/components/EngineSelector", () => ({
+ RunEngineSelector: ({
+ availableEngines,
+ value,
+ }: {
+ availableEngines: RunEngine[];
+ value: RunEngine | null;
+ }) => (
+ <div
+ data-testid="engine-selector"
+ data-value={value ?? ""}
+ data-available-engines={availableEngines.join(",")}
+ />
+ ),
+}));
+
+vi.mock("@/components/HelpTooltip", () => ({
+ HelpTooltip: () => null,
+}));
+
+vi.mock("@/components/ModelSelector", () => ({
+ ModelSelector: () => null,
+}));
+
+vi.mock("@/components/WorkflowBlockInput", () => ({
+ WorkflowBlockInput: () => null,
+}));
+
+vi.mock("@/components/WorkflowBlockInputTextarea", () => ({
+ WorkflowBlockInputTextarea: () => null,
+}));
+
+vi.mock("@/components/ui/accordion", () => ({
+ Accordion: ({ children }: { children?: ReactNode }) => <div>{children}</div>,
+ AccordionContent: ({ children }: { children?: ReactNode }) => (
+ <div>{children}</div>
+ ),
+ AccordionItem: ({ children }: { children?: ReactNode }) => (
+ <div>{children}</div>
+ ),
+ AccordionTrigger: ({ children }: { children?: ReactNode }) => (
+ <div>{children}</div>
+ ),
+}));
+
+vi.mock("@/components/ui/input", () => ({
+ Input: () => null,
+}));
+
+vi.mock("@/components/ui/label", () => ({
+ Label: ({ children }: { children?: ReactNode }) => <label>{children}</label>,
+}));
+
+vi.mock("@/components/ui/separator", () => ({
+ Separator: () => null,
+}));
+
+vi.mock("@/components/ui/switch", () => ({
+ Switch: () => null,
+}));
+
+vi.mock("../../useUpdate", () => ({
+ useUpdate: () => vi.fn(),
+}));
+
+vi.mock("../../panels/useHasInteractedThisSession", () => ({
+ useHasInteractedThisSession: () => true,
+}));
+
+vi.mock("../../workflowEditorUtils", () => ({
+ getAvailableOutputParameterKeys: () => [],
+ getParentLoopSkipsOnFail: () => false,
+ isNodeInsideForLoop: () => false,
+}));
+
+vi.mock("../DisableCache", () => ({
+ DisableCache: () => null,
+}));
+
+vi.mock("../IgnoreWorkflowSystemPrompt", () => ({
+ IgnoreWorkflowSystemPrompt: () => null,
+}));
+
+vi.mock("../components/BlockExecutionOptions", () => ({
+ BlockExecutionOptions: () => null,
+}));
+
+vi.mock("../TaskNode/ParametersMultiSelect", () => ({
+ ParametersMultiSelect: () => null,
+}));
+
+vi.mock("@/routes/workflows/editor/ErrorCodeMappingEditor", () => ({
+ ErrorCodeMappingEditor: () => null,
+}));
+
+function setNavigationNode(
+ engine: RunEngine,
+ overrides: Partial<NavigationNodeData> = {},
+) {
+ nodeData = {
+ type: "navigation",
+ data: {
+ ...navigationNodeDefaultData,
+ label: "navigate",
+ engine,
+ ...overrides,
+ },
+ };
+}
+
+afterEach(() => {
+ cleanup();
+ nodeData = null;
+});
+
+describe("NavigationEditor engine options", () => {
+ test("does not offer V2 for new V1 navigation blocks", () => {
+ setNavigationNode(RunEngine.SkyvernV1);
+
+ render(<NavigationEditor blockId="nav-1" />);
+
+ expect(
+ screen
+ .getByTestId("engine-selector")
+ .getAttribute("data-available-engines"),
+ ).toBe("skyvern-1.0,openai-cua,anthropic-cua");
+ });
+
+ test("keeps V2 available when editing an existing V2 block", () => {
+ setNavigationNode(RunEngine.SkyvernV2);
+
+ render(<NavigationEditor blockId="nav-1" />);
+
+ expect(
+ screen
+ .getByTestId("engine-selector")
+ .getAttribute("data-available-engines"),
+ ).toBe("skyvern-1.0,skyvern-2.0,openai-cua,anthropic-cua");
+ });
+
+ test("keeps V2 available after a remount when a legacy V2 block has switched to V1", () => {
+ setNavigationNode(RunEngine.SkyvernV1, { legacyV2Available: true });
+ render(<NavigationEditor blockId="nav-1" />);
+
+ expect(
+ screen
+ .getByTestId("engine-selector")
+ .getAttribute("data-available-engines"),
+ ).toBe("skyvern-1.0,skyvern-2.0,openai-cua,anthropic-cua");
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.tsx
index a588eee8b..67f0c03a7 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/NavigationEditor.tsx
@@ -70,11 +70,23 @@ function NavigationEditorBody({
const isInsideForLoop = isNodeInsideForLoop(nodes, blockId);
const parentLoopSkipsOnFail = getParentLoopSkipsOnFail(nodes, blockId);
const isV2Mode = data.engine === RunEngine.SkyvernV2;
+ const allowLegacyV2Selection = data.legacyV2Available || isV2Mode;
+ const availableEngines = allowLegacyV2Selection
+ ? [
+ RunEngine.SkyvernV1,
+ RunEngine.SkyvernV2,
+ RunEngine.OpenaiCua,
+ RunEngine.AnthropicCua,
+ ]
+ : [RunEngine.SkyvernV1, RunEngine.OpenaiCua, RunEngine.AnthropicCua];
const hasInteracted = useHasInteractedThisSession();
const handleEngineChange = (value: RunEngine) => {
if (!editable) return;
- const updates: Partial<NavigationNodeData> = { engine: value };
+ const updates: Partial<NavigationNodeData> = {
+ engine: value,
+ legacyV2Available: allowLegacyV2Selection,
+ };
if (value === RunEngine.SkyvernV2) {
updates.prompt = data.navigationGoal || data.prompt;
updates.navigationGoal = "";
@@ -131,12 +143,7 @@ function NavigationEditorBody({
value={data.engine}
onChange={handleEngineChange}
className="nopan w-72 text-xs"
- availableEngines={[
- RunEngine.SkyvernV1,
- RunEngine.SkyvernV2,
- RunEngine.OpenaiCua,
- RunEngine.AnthropicCua,
- ]}
+ availableEngines={availableEngines}
/>
</div>
</div>
@@ -281,12 +288,7 @@ function NavigationEditorBody({
value={data.engine}
onChange={handleEngineChange}
className="nopan w-72 text-xs"
- availableEngines={[
- RunEngine.SkyvernV1,
- RunEngine.SkyvernV2,
- RunEngine.OpenaiCua,
- RunEngine.AnthropicCua,
- ]}
+ availableEngines={availableEngines}
/>
</div>
</div>
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 11eb7afbb..b513a55be 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NavigationNode/types.ts
@@ -21,6 +21,7 @@ export type NavigationNodeData = NodeBaseData & {
totpIdentifier: string | null;
disableCache: boolean;
includeActionHistoryInVerification: boolean;
+ legacyV2Available: boolean;
// V2-specific fields (used when engine is SkyvernV2)
prompt: string;
maxSteps: number | null;
@@ -49,6 +50,7 @@ export const navigationNodeDefaultData: NavigationNodeData = {
continueOnFailure: false,
disableCache: false,
includeActionHistoryInVerification: false,
+ legacyV2Available: false,
ignoreWorkflowSystemPrompt: false,
// V2-specific fields
prompt: "",
diff --git a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
index cf993581d..6082bb1c6 100644
--- a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts
@@ -709,6 +709,7 @@ function convertToNode(
downloadSuffix: null,
parameterKeys: [],
includeActionHistoryInVerification: false,
+ legacyV2Available: true,
},
};
}
@@ -770,6 +771,7 @@ function convertToNode(
completeCriterion: block.complete_criterion ?? "",
terminateCriterion: block.terminate_criterion ?? "",
engine: block.engine ?? RunEngine.SkyvernV1,
+ legacyV2Available: isV2Engine,
includeActionHistoryInVerification:
block.include_action_history_in_verification ?? false,
// When engine is SkyvernV2, use navigation_goal as the prompt
@@ -2238,7 +2240,8 @@ function createNode(
};
}
case "taskv2": {
- // Redirect taskv2 creation to navigation with SkyvernV2 engine
+ // Defensive fallback for stale callers that still request the removed
+ // add-menu type. Persisted task_v2 blocks are preserved by blockToNode.
return {
...identifiers,
...common,
@@ -2246,7 +2249,6 @@ function createNode(
data: {
...navigationNodeDefaultData,
label,
- engine: RunEngine.SkyvernV2,
},
};
}
diff --git a/skyvern/cli/browser.py b/skyvern/cli/browser.py
index 3cd64a424..7c6387803 100644
--- a/skyvern/cli/browser.py
+++ b/skyvern/cli/browser.py
@@ -4,16 +4,10 @@ import time
from typing import Any, Optional
from urllib.parse import urlparse
-import requests # type: ignore
from rich.panel import Panel
from rich.prompt import Confirm, Prompt
from .console import console
-from .core.browser_launcher import (
- SKYVERN_DATA_DIR,
- clone_local_chrome_profile,
- get_local_chrome_profile_dir,
-)
# Ports to scan when auto-discovering a CDP debugging server
_CDP_SCAN_PORTS = [9222, 9223, 9224, 9225, 9226, 9229]
@@ -72,6 +66,8 @@ def _discover_cdp_server() -> Optional[tuple[str, dict | None]]:
- "ws://127.0.0.1:{port}/devtools/browser" if only WS is available
version_info is cached to avoid a redundant probe in _print_cdp_info.
"""
+ import requests # type: ignore
+
for port in _CDP_SCAN_PORTS:
http_url = f"http://127.0.0.1:{port}"
# Try HTTP first (standard --remote-debugging-port)
@@ -108,6 +104,8 @@ def _print_cdp_info(url: str, cached_info: dict | None = None) -> None:
return
# Standard HTTP CDP server
+ import requests # type: ignore
+
info = cached_info
if not info:
try:
@@ -171,6 +169,12 @@ def _print_classic_cdp_instructions() -> None:
def _setup_local_browser_clone() -> tuple[str, Optional[str], Optional[str]]:
"""Set up a new browser with the user's Chrome profile cloned."""
+ from .core.browser_launcher import ( # noqa: PLC0415
+ SKYVERN_DATA_DIR,
+ clone_local_chrome_profile,
+ get_local_chrome_profile_dir,
+ )
+
chrome_profile_dir = get_local_chrome_profile_dir()
if not chrome_profile_dir.is_dir():
console.print(
@@ -295,6 +299,8 @@ def _setup_local_browser_actual() -> tuple[str, Optional[str], Optional[str]]:
)
# Verify the manual URL
+ import requests # type: ignore
+
try:
response = requests.get(f"{manual_url}/json/version", timeout=2)
if response.status_code == 200:
diff --git a/skyvern/cli/init_command.py b/skyvern/cli/init_command.py
index 4dca63769..5613cba2d 100644
--- a/skyvern/cli/init_command.py
+++ b/skyvern/cli/init_command.py
@@ -4,7 +4,7 @@ import os
import subprocess
import sys
import uuid
-from collections.abc import Callable, Coroutine
+from collections.abc import Callable
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Literal, TypeVar, overload
@@ -25,7 +25,6 @@ from skyvern.utils.env_paths import (
resolve_backend_env_path,
)
-from .browser import setup_browser_config
from .console import console
from .database import setup_postgresql
from .llm_setup import setup_llm_providers, update_or_add_env_var
@@ -130,7 +129,12 @@ def _ensure_playwright_chromium(browser_type: str | None, skip_browser_install:
) as progress:
progress.add_task("[bold blue]Downloading Chromium, this may take a moment...", total=None)
try:
- subprocess.run(["playwright", "install", "chromium"], check=True, capture_output=True, text=True)
+ subprocess.run(
+ [sys.executable, "-m", "playwright", "install", "chromium"],
+ check=True,
+ capture_output=True,
+ text=True,
+ )
capture_setup_event("playwright-install-complete", success=True)
console.print("✅ [green]Chromium installation complete.[/green]")
return BrowserInstallStatus(required=True, ready=True, attempted=True)
@@ -293,7 +297,10 @@ def _install_server_extra_for_missing_dependency(exc: ImportError) -> None:
_SERVER_EXTRA_INSTALL_ATTEMPTED = True
console.print(f"📦 [bold blue]Installing {escape(target)}...[/bold blue]")
try:
- subprocess.run([sys.executable, "-m", "pip", "install", target], check=True)
+ subprocess.run(
+ [sys.executable, "-m", "pip", "install", "--retries", "5", "--timeout", "60", target],
+ check=True,
+ )
except subprocess.CalledProcessError as install_error:
console.print(f"[bold red]Failed to install {target}: {install_error}[/bold red]")
_print_local_server_dependency_hint(missing_module, target)
@@ -308,11 +315,27 @@ def _run_with_server_dependency_install(action: Callable[[], _T]) -> _T:
_install_server_extra_for_missing_dependency(exc)
+async def _setup_local_organization_from_database() -> str:
+ """Seed the local org/API key without constructing the full server runtime."""
+ from skyvern.config import settings # noqa: PLC0415
+
+ from .mcp import setup_local_organization_from_database_string # noqa: PLC0415
+
+ return await setup_local_organization_from_database_string(settings.DATABASE_STRING)
+
+
@overload
def init_env(
no_postgres: bool = False,
database_string: str = "",
skip_browser_install: bool = False,
+ mode: Literal["local", "cloud"] | None = None,
+ skip_llm_setup: bool = False,
+ configure_mcp: bool | None = None,
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,
+ browser_location: str | None = None,
+ remote_debugging_url: str | None = None,
+ analytics_id: str | None = None,
env_scope: str | None = None,
env_path: Path | str | None = None,
return_result: Literal[False] = False,
@@ -324,6 +347,13 @@ def init_env(
no_postgres: bool = False,
database_string: str = "",
skip_browser_install: bool = False,
+ mode: Literal["local", "cloud"] | None = None,
+ skip_llm_setup: bool = False,
+ configure_mcp: bool | None = None,
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,
+ browser_location: str | None = None,
+ remote_debugging_url: str | None = None,
+ analytics_id: str | None = None,
env_scope: str | None = None,
env_path: Path | str | None = None,
return_result: Literal[True] = True,
@@ -334,6 +364,13 @@ def init_env(
no_postgres: bool = False,
database_string: str = "",
skip_browser_install: bool = False,
+ mode: Literal["local", "cloud"] | None = None,
+ skip_llm_setup: bool = False,
+ configure_mcp: bool | None = None,
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,
+ browser_location: str | None = None,
+ remote_debugging_url: str | None = None,
+ analytics_id: str | None = None,
env_scope: str | None = None,
env_path: Path | str | None = None,
return_result: bool = False,
@@ -348,7 +385,7 @@ def init_env(
)
console.print("[italic]This wizard will help you set up Skyvern.[/italic]")
- infra_choice = Prompt.ask(
+ infra_choice = mode or Prompt.ask(
"Would you like to run Skyvern [bold blue]local[/bold blue]ly or in the [bold purple]cloud[/bold purple]?",
choices=["local", "cloud"],
)
@@ -385,27 +422,16 @@ def init_env(
console.print("✅ [green]Database migration complete.[/green]")
console.print("🔑 [bold blue]Generating local organization API key...[/bold blue]")
-
- def _load_start_forge_app() -> Callable[[], object]:
- from skyvern.forge.forge_app_initializer import start_forge_app # noqa: PLC0415
-
- return start_forge_app
-
- def _load_setup_local_organization() -> Callable[[], Coroutine[Any, Any, str]]:
- from .mcp import setup_local_organization # noqa: PLC0415
-
- return setup_local_organization
-
- start_forge_app = _run_with_server_dependency_install(_load_start_forge_app)
- setup_local_organization = _run_with_server_dependency_install(_load_setup_local_organization)
- _run_with_server_dependency_install(start_forge_app)
- api_key = _run_with_server_dependency_install(lambda: asyncio.run(setup_local_organization()))
+ api_key = _run_with_server_dependency_install(lambda: asyncio.run(_setup_local_organization_from_database()))
if api_key:
console.print("✅ [green]Local organization API key generated.[/green]")
else:
console.print("[red]Failed to generate local organization API key. Please check server logs.[/red]")
- if backend_env_path.exists():
+ if skip_llm_setup:
+ console.print("[yellow]Skipping LLM setup as requested.[/yellow]")
+ set_env_var("ENV", "local")
+ elif backend_env_path.exists():
console.print(f"💡 [{backend_env_path}] file already exists.", style="yellow", markup=False)
redo_llm_setup = Confirm.ask(
"Do you want to go through [bold yellow]LLM provider setup again[/bold yellow]?",
@@ -421,13 +447,29 @@ def init_env(
setup_llm_providers(env_path=backend_env_path)
console.print("\n[bold blue]Configuring browser settings...[/bold blue]")
- browser_type, browser_location, remote_debugging_url = setup_browser_config()
- result.browser_type = browser_type
- set_env_var("BROWSER_TYPE", browser_type)
- if browser_location:
- set_env_var("CHROME_EXECUTABLE_PATH", browser_location)
- if remote_debugging_url:
- set_env_var("BROWSER_REMOTE_DEBUGGING_URL", remote_debugging_url)
+ selected_browser_type: str
+ selected_browser_location: str | None
+ selected_remote_debugging_url: str | None
+ if browser_type:
+ selected_browser_type = browser_type
+ selected_browser_location = browser_location
+ selected_remote_debugging_url = remote_debugging_url
+ capture_setup_event(
+ "browser-config-select",
+ success=True,
+ extra_data={"type": selected_browser_type, "source": "cli-option"},
+ )
+ else:
+ from .browser import setup_browser_config # noqa: PLC0415
+
+ selected_browser_type, selected_browser_location, selected_remote_debugging_url = setup_browser_config()
+
+ result.browser_type = selected_browser_type
+ set_env_var("BROWSER_TYPE", selected_browser_type)
+ if selected_browser_location:
+ set_env_var("CHROME_EXECUTABLE_PATH", selected_browser_location)
+ if selected_remote_debugging_url:
+ set_env_var("BROWSER_REMOTE_DEBUGGING_URL", selected_remote_debugging_url)
set_env_var("BROWSER_STREAMING_MODE", "cdp")
console.print("✅ [green]Browser configuration complete.[/green]")
@@ -488,9 +530,11 @@ def init_env(
console.print(" This starts Chrome on your machine and creates a tunnel so Skyvern Cloud can control it.")
console.print(" Learn more: [link]https://www.skyvern.com/docs/optimization/browser-tunneling[/link]")
- analytics_id_input = Prompt.ask("Please enter your email for analytics (press enter to skip)", default="")
- analytics_id = analytics_id_input if analytics_id_input else str(uuid.uuid4())
- set_env_var("ANALYTICS_ID", analytics_id)
+ resolved_analytics_id = analytics_id
+ if resolved_analytics_id is None:
+ analytics_id_input = Prompt.ask("Please enter your email for analytics (press enter to skip)", default="")
+ resolved_analytics_id = analytics_id_input if analytics_id_input else str(uuid.uuid4())
+ set_env_var("ANALYTICS_ID", resolved_analytics_id)
if api_key:
set_env_var("SKYVERN_API_KEY", api_key)
console.print(f"✅ [green]{backend_env_path} file has been initialized.[/green]")
@@ -499,7 +543,14 @@ def init_env(
_mcp_browser_type = os.environ.get("BROWSER_TYPE") if run_local else None
_mcp_browser_url = os.environ.get("BROWSER_REMOTE_DEBUGGING_URL") if run_local else None
- if Confirm.ask("\nWould you like to [bold yellow]configure the MCP server[/bold yellow]?", default=True):
+ should_configure_mcp = configure_mcp
+ if should_configure_mcp is None:
+ should_configure_mcp = Confirm.ask(
+ "\nWould you like to [bold yellow]configure the MCP server[/bold yellow]?",
+ default=True,
+ )
+
+ if should_configure_mcp:
from .mcp import setup_mcp # noqa: PLC0415
setup_mcp(
@@ -567,6 +618,8 @@ def init_browser() -> None:
"""Initialize only the browser configuration and install Chromium."""
console.print("\n[bold blue]Configuring browser settings...[/bold blue]")
capture_setup_event("browser-config-start")
+ from .browser import setup_browser_config # noqa: PLC0415
+
browser_type, browser_location, remote_debugging_url = setup_browser_config()
update_or_add_env_var("BROWSER_TYPE", browser_type)
if browser_location:
diff --git a/skyvern/cli/mcp.py b/skyvern/cli/mcp.py
index 0c0b1fa57..2784173cc 100644
--- a/skyvern/cli/mcp.py
+++ b/skyvern/cli/mcp.py
@@ -1,31 +1,67 @@
+from __future__ import annotations
+
+import base64
+import hashlib
+import hmac
+import json
+from datetime import datetime, timedelta
+from typing import TYPE_CHECKING, Any
+
from rich.panel import Panel
from rich.prompt import Confirm
from skyvern.forge import app
-from skyvern.forge.sdk.core import security
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
-from skyvern.forge.sdk.schemas.organizations import Organization
-from skyvern.forge.sdk.services.local_org_auth_token_service import SKYVERN_LOCAL_DOMAIN, SKYVERN_LOCAL_ORG
-from skyvern.forge.sdk.services.org_auth_token_service import API_KEY_LIFETIME
from .console import console
from .setup_commands import setup_claude, setup_claude_code, setup_cursor, setup_windsurf
+if TYPE_CHECKING:
+ from skyvern.forge.sdk.schemas.organizations import Organization
+
+API_KEY_LIFETIME = timedelta(weeks=5200)
+SKYVERN_LOCAL_ORG = "Skyvern-local"
+SKYVERN_LOCAL_DOMAIN = "skyvern.local"
+
+
+def _base64url_encode(data: bytes) -> str:
+ return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
-async def get_or_create_local_organization() -> Organization:
- organization = await app.DATABASE.organizations.get_organization_by_domain(SKYVERN_LOCAL_DOMAIN)
+
+def _create_local_access_token(subject: str, expires_delta: timedelta) -> str:
+ from skyvern.config import settings # noqa: PLC0415
+
+ if settings.SIGNATURE_ALGORITHM != "HS256":
+ raise RuntimeError("Local quickstart token bootstrap only supports HS256 SIGNATURE_ALGORITHM")
+
+ expire = datetime.utcnow() + expires_delta
+ header = {"alg": "HS256", "typ": "JWT"}
+ payload = {"exp": int(expire.timestamp()), "sub": str(subject)}
+ signing_input = ".".join(
+ [
+ _base64url_encode(json.dumps(header, separators=(",", ":")).encode("utf-8")),
+ _base64url_encode(json.dumps(payload, separators=(",", ":")).encode("utf-8")),
+ ]
+ )
+ signature = hmac.new(settings.SECRET_KEY.encode("utf-8"), signing_input.encode("ascii"), hashlib.sha256).digest()
+ return f"{signing_input}.{_base64url_encode(signature)}"
+
+
+async def get_or_create_local_organization(database: Any | None = None) -> Organization:
+ database = database or app.DATABASE
+ organization = await database.organizations.get_organization_by_domain(SKYVERN_LOCAL_DOMAIN)
if not organization:
- organization = await app.DATABASE.organizations.create_organization(
+ organization = await database.organizations.create_organization(
organization_name=SKYVERN_LOCAL_ORG,
domain=SKYVERN_LOCAL_DOMAIN,
max_steps_per_run=10,
max_retries_per_step=3,
)
- api_key = security.create_access_token(
+ api_key = _create_local_access_token(
organization.organization_id,
expires_delta=API_KEY_LIFETIME,
)
- await app.DATABASE.organizations.create_org_auth_token(
+ await database.organizations.create_org_auth_token(
organization_id=organization.organization_id,
token=api_key,
token_type=OrganizationAuthTokenType.api,
@@ -33,15 +69,138 @@ async def get_or_create_local_organization() -> Organization:
return organization
-async def setup_local_organization() -> str:
- organization = await get_or_create_local_organization()
- org_auth_token = await app.DATABASE.organizations.get_valid_org_auth_token(
+async def setup_local_organization(database: Any | None = None) -> str:
+ database = database or app.DATABASE
+ organization = await get_or_create_local_organization(database=database)
+ org_auth_token = await database.organizations.get_valid_org_auth_token(
organization_id=organization.organization_id,
token_type=OrganizationAuthTokenType.api.value,
)
return org_auth_token.token if org_auth_token else ""
+async def setup_local_organization_from_database_string(database_string: str) -> str:
+ """Seed the local org/API key without importing the full repository graph."""
+ from sqlalchemy import text # noqa: PLC0415
+ from sqlalchemy.ext.asyncio import create_async_engine # noqa: PLC0415
+
+ from skyvern.forge.sdk.db.id import generate_org_id, generate_organization_auth_token_id # noqa: PLC0415
+
+ connect_args = {"prepare_threshold": None} if "postgresql+psycopg" in database_string else {}
+ engine = create_async_engine(database_string, connect_args=connect_args, pool_pre_ping=True)
+ try:
+ async with engine.begin() as connection:
+ organization_id = (
+ await connection.execute(
+ text("SELECT organization_id FROM organizations WHERE domain = :domain LIMIT 1"),
+ {"domain": SKYVERN_LOCAL_DOMAIN},
+ )
+ ).scalar_one_or_none()
+
+ if not organization_id:
+ organization_id = generate_org_id()
+ now = datetime.utcnow()
+ await connection.execute(
+ text(
+ """
+ INSERT INTO organizations (
+ organization_id,
+ organization_name,
+ domain,
+ max_steps_per_run,
+ max_retries_per_step,
+ created_at,
+ modified_at
+ )
+ VALUES (
+ :organization_id,
+ :organization_name,
+ :domain,
+ :max_steps_per_run,
+ :max_retries_per_step,
+ :created_at,
+ :modified_at
+ )
+ """
+ ),
+ {
+ "organization_id": organization_id,
+ "organization_name": SKYVERN_LOCAL_ORG,
+ "domain": SKYVERN_LOCAL_DOMAIN,
+ "max_steps_per_run": 10,
+ "max_retries_per_step": 3,
+ "created_at": now,
+ "modified_at": now,
+ },
+ )
+ api_key = _create_local_access_token(
+ organization_id,
+ expires_delta=API_KEY_LIFETIME,
+ )
+ await connection.execute(
+ text(
+ """
+ INSERT INTO organization_auth_tokens (
+ id,
+ organization_id,
+ token_type,
+ token,
+ encrypted_token,
+ encrypted_method,
+ valid,
+ created_at,
+ modified_at
+ )
+ VALUES (
+ :id,
+ :organization_id,
+ :token_type,
+ :token,
+ :encrypted_token,
+ :encrypted_method,
+ :valid,
+ :created_at,
+ :modified_at
+ )
+ """
+ ),
+ {
+ "id": generate_organization_auth_token_id(),
+ "organization_id": organization_id,
+ "token_type": OrganizationAuthTokenType.api.value,
+ "token": api_key,
+ "encrypted_token": "",
+ "encrypted_method": "",
+ "valid": True,
+ "created_at": now,
+ "modified_at": now,
+ },
+ )
+
+ token = (
+ await connection.execute(
+ text(
+ """
+ SELECT token
+ FROM organization_auth_tokens
+ WHERE organization_id = :organization_id
+ AND token_type = :token_type
+ AND valid = true
+ ORDER BY created_at DESC
+ LIMIT 1
+ """
+ ),
+ {
+ "organization_id": organization_id,
+ "token_type": OrganizationAuthTokenType.api.value,
+ },
+ )
+ ).scalar_one_or_none()
+ return token or ""
+ finally:
+ await engine.dispose()
+
+
def setup_mcp(
*,
local: bool = False,
diff --git a/skyvern/cli/quickstart.py b/skyvern/cli/quickstart.py
index c59316151..022d09587 100644
--- a/skyvern/cli/quickstart.py
+++ b/skyvern/cli/quickstart.py
@@ -9,7 +9,7 @@ import subprocess
import sys
from enum import Enum
from pathlib import Path
-from typing import Any
+from typing import Any, Literal
import typer
from rich.markup import escape
@@ -38,7 +38,7 @@ def _server_extra_install_target() -> str:
return f"skyvern[server]=={version}"
-def _install_server_extra_for_quickstart() -> bool:
+def _install_server_extra_for_quickstart(*, assume_yes: bool = False) -> bool:
target = _server_extra_install_target()
console.print(
Panel(
@@ -48,13 +48,16 @@ def _install_server_extra_for_quickstart() -> bool:
border_style="yellow",
)
)
- if not Confirm.ask("Install the missing server dependencies now?", default=True):
+ if not assume_yes and not Confirm.ask("Install the missing server dependencies now?", default=True):
_print_server_guidance()
return False
console.print(f"📦 [bold blue]Installing {escape(target)}...[/bold blue]")
try:
- subprocess.run([sys.executable, "-m", "pip", "install", target], check=True)
+ subprocess.run(
+ [sys.executable, "-m", "pip", "install", "--retries", "5", "--timeout", "60", target],
+ check=True,
+ )
except subprocess.CalledProcessError as install_error:
console.print(f"[bold red]Failed to install {target}: {install_error}[/bold red]")
_print_server_guidance()
@@ -223,6 +226,43 @@ def _server_quickstart_flags_requested(
return no_postgres or bool(database_string) or skip_browser_install or server_only
+def _server_quickstart_options(
+ *,
+ no_postgres: bool,
+ database_string: str,
+ skip_browser_install: bool,
+ server_only: bool,
+ skip_llm_setup: bool,
+ configure_mcp: bool | None,
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None,
+ browser_location: str | None,
+ remote_debugging_url: str | None,
+ analytics_id: str | None,
+ start_services_now: bool | None,
+) -> dict[str, Any]:
+ options: dict[str, Any] = {
+ "no_postgres": no_postgres,
+ "database_string": database_string,
+ "skip_browser_install": skip_browser_install,
+ "server_only": server_only,
+ }
+ if skip_llm_setup:
+ options["skip_llm_setup"] = skip_llm_setup
+ if configure_mcp is not None:
+ options["configure_mcp"] = configure_mcp
+ if browser_type is not None:
+ options["browser_type"] = browser_type
+ if browser_location is not None:
+ options["browser_location"] = browser_location
+ if remote_debugging_url is not None:
+ options["remote_debugging_url"] = remote_debugging_url
+ if analytics_id is not None:
+ options["analytics_id"] = analytics_id
+ if start_services_now is not None:
+ options["start_services_now"] = start_services_now
+ return options
+
+
def _parse_quickstart_env_scope(value: str) -> EnvScope:
try:
return parse_env_scope(value)
@@ -287,6 +327,13 @@ def _run_server_quickstart(
database_string: str,
skip_browser_install: bool,
server_only: bool,
+ skip_llm_setup: bool = False,
+ configure_mcp: bool | None = None,
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = None,
+ browser_location: str | None = None,
+ remote_debugging_url: str | None = None,
+ analytics_id: str | None = None,
+ start_services_now: bool | None = None,
) -> None:
try:
from skyvern.cli.init_command import init_env # noqa: PLC0415
@@ -298,6 +345,13 @@ def _run_server_quickstart(
no_postgres=no_postgres,
database_string=database_string,
skip_browser_install=skip_browser_install,
+ mode="local",
+ skip_llm_setup=skip_llm_setup,
+ configure_mcp=configure_mcp,
+ browser_type=browser_type,
+ browser_location=browser_location,
+ remote_debugging_url=remote_debugging_url,
+ analytics_id=analytics_id,
return_result=True,
)
run_local = bool(init_result)
@@ -323,7 +377,11 @@ def _run_server_quickstart(
)
return
- start_now = typer.confirm("\nDo you want to start Skyvern services now?", default=True)
+ start_now = (
+ start_services_now
+ if start_services_now is not None
+ else typer.confirm("\nDo you want to start Skyvern services now?", default=True)
+ )
if start_now:
console.print("\n[bold blue]Starting Skyvern services...[/bold blue]")
asyncio.run(start_services(server_only=server_only))
@@ -727,12 +785,78 @@ def quickstart(
"--env-scope",
help="Backend env location for setup writes: legacy/current, project, or global.",
),
+ yes: bool = typer.Option(
+ False,
+ "--yes",
+ "-y",
+ help="Automatically approve installing missing Skyvern server dependencies.",
+ ),
+ non_interactive: bool = typer.Option(
+ False,
+ "--non-interactive",
+ help=(
+ "Run the self-hosted server quickstart path without prompts. Installs missing server dependencies, "
+ "skips LLM/MCP prompts, uses headless Chromium, anonymous analytics, and does not start services."
+ ),
+ ),
+ skip_llm_setup: bool = typer.Option(
+ False,
+ "--skip-llm-setup",
+ help="Skip interactive LLM provider setup and keep/default environment values.",
+ ),
+ skip_mcp: bool = typer.Option(False, "--skip-mcp", help="Skip interactive MCP server configuration."),
+ browser_type: Literal["chromium-headful", "chromium-headless", "cdp-connect"] | None = typer.Option(
+ None,
+ "--browser-type",
+ help="Browser type to write without prompting.",
+ ),
+ browser_location: str | None = typer.Option(
+ None,
+ "--browser-location",
+ help="Chrome executable path to write when using a custom browser location.",
+ ),
+ remote_debugging_url: str | None = typer.Option(
+ None,
+ "--remote-debugging-url",
+ help="CDP URL to write when using --browser-type cdp-connect.",
+ ),
+ analytics_id: str | None = typer.Option(
+ None,
+ "--analytics-id",
+ help="Analytics identifier to write without prompting. Use 'anonymous' for agent tests.",
+ ),
+ start_services_now: bool | None = typer.Option(
+ None,
+ "--start/--no-start",
+ help="Start Skyvern services after setup. Omit to prompt.",
+ ),
) -> None:
"""Quickstart command to set up and run Skyvern with one command."""
# Run initialization
console.print(Panel("[bold green]🚀 Starting Skyvern Quickstart[/bold green]", border_style="green"))
install_type_value = install_type if isinstance(install_type, str) else None
env_scope_value = env_scope if isinstance(env_scope, str) else None
+ if non_interactive:
+ install_type_value = install_type_value or QuickstartPath.SERVER.value
+ yes = True
+ skip_llm_setup = True
+ skip_mcp = True
+ browser_type = browser_type or "chromium-headless"
+ analytics_id = analytics_id or "anonymous"
+ if start_services_now is None:
+ start_services_now = False
+ if not database_string:
+ no_postgres = True
+ console.print(
+ Panel(
+ "[bold yellow]Non-interactive quickstart will not prompt to start PostgreSQL.[/bold yellow]\n\n"
+ "No [cyan]--database-string[/cyan] was provided, so Skyvern will use any existing "
+ "[cyan]DATABASE_STRING[/cyan] from your environment or .env file.\n\n"
+ "For unattended agent tests, pass "
+ "[cyan]--database-string postgresql+psycopg://user:pass@host:5432/dbname[/cyan].",
+ border_style="yellow",
+ )
+ )
has_server_extra = _has_server_quickstart_extra()
# The server extra is a superset of the local embedded runtime dependencies.
@@ -744,6 +868,16 @@ def quickstart(
server_only=server_only,
)
if docker_compose:
+ if non_interactive:
+ console.print(
+ Panel(
+ "[bold red]Non-interactive Docker Compose quickstart is not supported yet.[/bold red]\n"
+ "Use [cyan]--install-type server --database-string postgresql+psycopg://...[/cyan] "
+ "for unattended agent tests.",
+ border_style="red",
+ )
+ )
+ raise typer.Exit(1)
selected_path = (
QuickstartPath.SERVER if install_type_value is None else _parse_quickstart_path(install_type_value)
)
@@ -820,7 +954,7 @@ def quickstart(
return
# If Docker Compose file exists, offer the choice
- if docker_compose_available and check_docker() and not server_flags_requested:
+ if not non_interactive and docker_compose_available and check_docker() and not server_flags_requested:
console.print("\n[bold blue]Setup Method[/bold blue]")
console.print("Docker Compose file detected. Choose your setup method:\n")
console.print(" [cyan]1.[/cyan] [green]Docker Compose (Recommended)[/green] - Full containerized setup")
@@ -836,15 +970,24 @@ def quickstart(
return
if not _has_server_quickstart_extra():
- if not _is_interactive_input():
+ if not yes and not _is_interactive_input():
_print_server_guidance()
raise typer.Exit(0)
- if not _install_server_extra_for_quickstart() or not _has_server_quickstart_extra():
+ if not _install_server_extra_for_quickstart(assume_yes=yes) or not _has_server_quickstart_extra():
raise typer.Exit(1)
_run_server_quickstart(
- no_postgres=no_postgres,
- database_string=database_string,
- skip_browser_install=skip_browser_install,
- server_only=server_only,
+ **_server_quickstart_options(
+ no_postgres=no_postgres,
+ database_string=database_string,
+ skip_browser_install=skip_browser_install,
+ server_only=server_only,
+ skip_llm_setup=skip_llm_setup,
+ configure_mcp=False if skip_mcp else None,
+ browser_type=browser_type,
+ browser_location=browser_location,
+ remote_debugging_url=remote_debugging_url,
+ analytics_id=analytics_id,
+ start_services_now=start_services_now,
+ )
)
diff --git a/skyvern/client/client.py b/skyvern/client/client.py
index dcb38f6d1..74bf507d3 100644
--- a/skyvern/client/client.py
+++ b/skyvern/client/client.py
@@ -179,7 +179,7 @@ class Skyvern:
engine : typing.Optional[RunEngine]
- The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+ The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
title : typing.Optional[str]
The title for the task
@@ -254,7 +254,7 @@ class Skyvern:
The extra HTTP headers for the requests in browser.
publish_workflow : typing.Optional[bool]
- Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.
+ Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.
include_action_history_in_verification : typing.Optional[bool]
Whether to include action history when verifying that the task is complete
@@ -2629,7 +2629,7 @@ class AsyncSkyvern:
engine : typing.Optional[RunEngine]
- The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+ The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
title : typing.Optional[str]
The title for the task
@@ -2704,7 +2704,7 @@ class AsyncSkyvern:
The extra HTTP headers for the requests in browser.
publish_workflow : typing.Optional[bool]
- Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.
+ Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.
include_action_history_in_verification : typing.Optional[bool]
Whether to include action history when verifying that the task is complete
diff --git a/skyvern/client/raw_client.py b/skyvern/client/raw_client.py
index 5166a6574..d3f7fc15b 100644
--- a/skyvern/client/raw_client.py
+++ b/skyvern/client/raw_client.py
@@ -104,7 +104,7 @@ class RawSkyvern:
engine : typing.Optional[RunEngine]
- The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+ The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
title : typing.Optional[str]
The title for the task
@@ -179,7 +179,7 @@ class RawSkyvern:
The extra HTTP headers for the requests in browser.
publish_workflow : typing.Optional[bool]
- Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.
+ Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.
include_action_history_in_verification : typing.Optional[bool]
Whether to include action history when verifying that the task is complete
@@ -3513,7 +3513,7 @@ class AsyncRawSkyvern:
engine : typing.Optional[RunEngine]
- The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+ The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
title : typing.Optional[str]
The title for the task
@@ -3588,7 +3588,7 @@ class AsyncRawSkyvern:
The extra HTTP headers for the requests in browser.
publish_workflow : typing.Optional[bool]
- Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.
+ Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.
include_action_history_in_verification : typing.Optional[bool]
Whether to include action history when verifying that the task is complete
diff --git a/skyvern/client/types/task_run_request.py b/skyvern/client/types/task_run_request.py
index a85b7a910..cf280707b 100644
--- a/skyvern/client/types/task_run_request.py
+++ b/skyvern/client/types/task_run_request.py
@@ -25,7 +25,7 @@ class TaskRunRequest(UniversalBaseModel):
engine: typing.Optional[RunEngine] = pydantic.Field(default=None)
"""
- The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+ The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
"""
title: typing.Optional[str] = pydantic.Field(default=None)
@@ -124,7 +124,7 @@ class TaskRunRequest(UniversalBaseModel):
publish_workflow: typing.Optional[bool] = pydantic.Field(default=None)
"""
- Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.
+ Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. For backwards compatibility, this routes the request through the legacy `skyvern-2.0` publish path. Prefer creating reusable workflows through the workflow APIs.
"""
include_action_history_in_verification: typing.Optional[bool] = pydantic.Field(default=None)
diff --git a/skyvern/core/script_generations/real_skyvern_page_ai.py b/skyvern/core/script_generations/real_skyvern_page_ai.py
index 26a6e5c45..550874c3d 100644
--- a/skyvern/core/script_generations/real_skyvern_page_ai.py
+++ b/skyvern/core/script_generations/real_skyvern_page_ai.py
@@ -42,6 +42,7 @@ from skyvern.webeye.actions.handler import (
handle_upload_file_action,
)
from skyvern.webeye.actions.parse_actions import parse_actions
+from skyvern.webeye.scraper.non_vision_context import build_non_vision_page_context_if_needed
from skyvern.webeye.scraper.scraped_page import ScrapedPage
jinja_sandbox_env = SandboxedEnvironment()
@@ -198,6 +199,10 @@ class RealSkyvernPageAi(SkyvernPageAi):
elements=element_tree,
local_datetime=datetime.now(context.tz_info or datetime.now().astimezone().tzinfo).isoformat(),
user_context=context.prompt,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=self.scraped_page,
+ page=getattr(self, "page", None),
+ ),
)
json_response = await app.SINGLE_CLICK_AGENT_LLM_API_HANDLER(
prompt=single_click_prompt,
@@ -1154,6 +1159,10 @@ class RealSkyvernPageAi(SkyvernPageAi):
extracted_text=extracted_text_for_prompt,
error_code_mapping_str=error_code_mapping_str,
local_datetime=local_datetime_str,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=self.scraped_page,
+ page=getattr(self, "page", None),
+ ),
)
# Cache extract-information within this script-generation path. The
@@ -1196,6 +1205,7 @@ class RealSkyvernPageAi(SkyvernPageAi):
error_code_mapping=error_code_mapping_str,
llm_key=None,
workflow_system_prompt=workflow_system_prompt,
+ non_vision_page_context=post_ceiling_kwargs.get("non_vision_page_context"),
)
lookup_result = extraction_cache.lookup(workflow_run_id, cache_key)
except Exception:
@@ -1319,6 +1329,10 @@ class RealSkyvernPageAi(SkyvernPageAi):
data_extraction_goal=prompt_rendered,
current_url=scraped_page_refreshed.url,
local_datetime=datetime.now(context.tz_info or datetime.now().astimezone().tzinfo).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page_refreshed,
+ page=getattr(self, "page", None),
+ ),
)
step = None
@@ -1476,6 +1490,10 @@ class RealSkyvernPageAi(SkyvernPageAi):
current_url=self.page.url,
elements=element_tree,
local_datetime=local_datetime,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=self.scraped_page,
+ page=getattr(self, "page", None),
+ ),
)
try:
@@ -1502,6 +1520,10 @@ class RealSkyvernPageAi(SkyvernPageAi):
current_url=self.page.url,
elements=element_tree,
local_datetime=local_datetime,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=self.scraped_page,
+ page=getattr(self, "page", None),
+ ),
)
action_response = await llm_handler(
prompt=single_action_prompt,
diff --git a/skyvern/exceptions.py b/skyvern/exceptions.py
index c93b5f0de..c89854c44 100644
--- a/skyvern/exceptions.py
+++ b/skyvern/exceptions.py
@@ -8,9 +8,11 @@ from typing import NoReturn
# the heavy modules users commonly have partially installed.
_LOCAL_EXTRA_SENTINELS = (
"fastapi",
+ "fuzzysearch",
"jinja2",
"libcst",
"litellm",
+ "openai",
"playwright",
"sqlalchemy",
"starlette",
@@ -22,7 +24,7 @@ _LOCAL_EXTRA_SENTINELS = (
# server sentinels local-compatible so those imports continue to work in
# skyvern[local]. Full server entrypoints pass server-only module_names such as
# "uvicorn" when they need to fail for local-only installs.
-_SERVER_EXTRA_SENTINELS = tuple(_LOCAL_EXTRA_SENTINELS)
+_SERVER_EXTRA_SENTINELS = tuple(dict.fromkeys((*_LOCAL_EXTRA_SENTINELS, "alembic", "anthropic")))
_EXTRA_SUPPORT_LABELS = {
"local": "local embedded/browser support",
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index 080e49dcf..2cdabc836 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -157,6 +157,7 @@ from skyvern.webeye.actions.parse_actions import (
)
from skyvern.webeye.actions.responses import ActionResult, ActionSuccess
from skyvern.webeye.browser_state import BrowserState
+from skyvern.webeye.scraper.non_vision_context import build_non_vision_page_context_if_needed
from skyvern.webeye.scraper.scraped_page import ElementTreeFormat, ScrapedPage
from skyvern.webeye.utils.page import SkyvernFrame
@@ -2278,6 +2279,7 @@ class ForgeAgent:
call_kwargs: dict[str, Any] = {
"step": step,
"screenshots": scraped_page.screenshots,
+ "prompt_name": "anthropic-cua",
"use_message_history": True,
"tools": tools,
"raw_response": True,
@@ -2781,6 +2783,10 @@ class ForgeAgent:
# no new_elements_ids threading — so we also drop Skyvern IDs.
_ctx = skyvern_context.current()
lean_enabled = bool(_ctx and _ctx.enable_lean_element_tree)
+ non_vision_page_context = await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page_refreshed,
+ page=page,
+ )
verification_prompt = load_prompt_with_elements(
element_tree_builder=scraped_page_refreshed,
prompt_engine=prompt_engine,
@@ -2791,6 +2797,7 @@ class ForgeAgent:
terminate_criterion=task.terminate_criterion,
action_history=actions_and_results_str,
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
+ non_vision_page_context=non_vision_page_context,
html_need_skyvern_attrs=False,
lean_compress_long_href=lean_enabled,
lean_compress_image_src=lean_enabled,
@@ -3483,6 +3490,7 @@ class ForgeAgent:
verification_code_check: bool,
show_close_page_action: bool,
complete_criterion: str | None,
+ non_vision_enabled: bool = False,
) -> str:
"""
Build a short-but-unique cache variant identifier so extract-action prompts that
@@ -3494,6 +3502,8 @@ class ForgeAgent:
variant_parts.append("vc")
if show_close_page_action:
variant_parts.append("cp")
+ if non_vision_enabled:
+ variant_parts.append("nv")
if complete_criterion:
normalized = " ".join(complete_criterion.split())
digest = hashlib.sha256(normalized.encode("utf-8"), usedforsecurity=False).hexdigest()[:6]
@@ -3765,6 +3775,10 @@ class ForgeAgent:
open_tabs_context = await _build_open_tabs_context(browser_state, page)
show_close_page_action = open_tabs_context is not None
+ non_vision_page_context = await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page,
+ page=page,
+ )
# Format-then-clear so a render failure can't drop the signal permanently;
# gate on extract-action template since other task types don't render it.
@@ -3792,11 +3806,13 @@ class ForgeAgent:
"show_close_page_action": show_close_page_action,
"open_tabs_context": open_tabs_context,
"recent_dialog_messages_str": recent_dialog_messages_str,
+ "non_vision_page_context": non_vision_page_context,
}
cache_variant = self._build_extract_action_cache_variant(
verification_code_check=verification_code_check,
show_close_page_action=show_close_page_action,
complete_criterion=task.complete_criterion.strip() if task.complete_criterion else None,
+ non_vision_enabled=bool(non_vision_page_context),
)
static_prompt = prompt_engine.load_prompt(f"{template}-static", **prompt_kwargs)
dynamic_prompt = prompt_engine.load_prompt(
@@ -3884,6 +3900,7 @@ class ForgeAgent:
show_close_page_action=show_close_page_action,
open_tabs_context=open_tabs_context,
recent_dialog_messages_str=recent_dialog_messages_str,
+ non_vision_page_context=non_vision_page_context,
# SKY-9718 Layer 1: planner non-cached fallback. Keep Skyvern IDs
# (default html_need_skyvern_attrs=True) — the planner emits
# `click(id=...)` references. Gate lean on the PostHog flag.
@@ -5290,6 +5307,7 @@ class ForgeAgent:
steps=steps_results,
error_code_mapping_str=(json.dumps(task.error_code_mapping) if task.error_code_mapping else None),
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(page=page),
)
json_response = await app.LLM_API_HANDLER(
prompt=prompt,
@@ -5435,6 +5453,7 @@ class ForgeAgent:
max_retries=max_retries,
error_code_mapping_str=(json.dumps(task.error_code_mapping) if task.error_code_mapping else None),
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(page=page),
)
json_response = await app.SECONDARY_LLM_API_HANDLER(
prompt=prompt,
diff --git a/skyvern/forge/prompts/skyvern/custom-select.j2 b/skyvern/forge/prompts/skyvern/custom-select.j2
index f1aa13846..d35fdf7fc 100644
--- a/skyvern/forge/prompts/skyvern/custom-select.j2
+++ b/skyvern/forge/prompts/skyvern/custom-select.j2
@@ -7,10 +7,9 @@ You can identify the matching element based on the following guidelines:
- If a field is required, do not leave it blank.
- If a field is required, do not select a placeholder value, such as "Please select", "-", or "Select...".
- Exclude loading indicators like "loading more results" as valid options.{% if new_elements_ids %}
- - The matching element can only be in the emerging elements.{% endif %}{% if is_date_related %}
- - A date picker might be triggered. Use the target value when provided, the user goal, and visible date controls to set the requested date range.
- - Do not choose "Today" unless the target date is today.{% endif %}{% if select_history %}
- - The selection history displays the previously selected values for the multi-level selection. Continue to complete the entire selection process.{% endif %}
+ - The matching element can only be in the emerging elements.{% endif %}{% if select_history %}
+ - The selection history displays the previously selected values for the multi-level selection. Continue to complete the entire selection process.{% if is_date_related %}
+ - Date picker might be triggered, you goal is to set the correct start date and end date.{% endif %}{% endif %}
MAKE SURE YOU OUTPUT VALID JSON. No text before or after JSON, no trailing commas, no comments (//), no unnecessary quotes, etc.
Each interactable element is tagged with an ID.
@@ -64,4 +63,4 @@ Select History:
Current datetime, ISO format:
```
{{ local_datetime }}
-```
+```
\ No newline at end of file
diff --git a/skyvern/forge/prompts/skyvern/extract-action-dynamic.j2 b/skyvern/forge/prompts/skyvern/extract-action-dynamic.j2
index b8c4a8cc2..55939c565 100644
--- a/skyvern/forge/prompts/skyvern/extract-action-dynamic.j2
+++ b/skyvern/forge/prompts/skyvern/extract-action-dynamic.j2
@@ -40,6 +40,12 @@ Open browser tabs (CLOSE_PAGE always closes the tab marked [current] — other t
{{ open_tabs_context }}
```
{% endif %}
+{% if non_vision_page_context %}
+Non-vision page context and accessibility tree:
+```json
+{{ non_vision_page_context }}
+```
+{% endif %}
Clickable elements from `{{ current_url }}`:
```
{{ elements }}
diff --git a/skyvern/forge/prompts/skyvern/extract-action-static.j2 b/skyvern/forge/prompts/skyvern/extract-action-static.j2
index f040a4571..bf1ac47c5 100644
--- a/skyvern/forge/prompts/skyvern/extract-action-static.j2
+++ b/skyvern/forge/prompts/skyvern/extract-action-static.j2
@@ -1,11 +1,13 @@
-Identify actions to help user progress towards the user goal using the DOM elements given in the list and the screenshot of the website.
+Identify actions to help user progress towards the user goal using the DOM elements given in the list{% if non_vision_page_context %}, the non-vision page context, and the accessibility tree of the website{% else %} and the screenshot of the website{% endif %}.
Include only the elements that are relevant to the user goal, without altering or imagining new elements.
Accurately interpret and understand the functional significance of SVG elements based on their shapes and context within the webpage.
Use the user details to fill in necessary values. Always satisfy required fields if the field isn't already filled in. Don't return any action for the same field, if this field is already filled in and the value is the same as the one you would have filled in.
MAKE SURE YOU OUTPUT VALID JSON. No text before or after JSON, no trailing commas, no comments (//), no unnecessary quotes, etc.
Each interactable element is tagged with an ID. Avoid taking action on a disabled element when there is an alternative action available.
-If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
+{% if non_vision_page_context %}If the non-vision page context shows invalid fields, validation messages, error-colored text, dialogs, overlays, or expanded controls, prioritize actions that address those states.
+{% else %}If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
If you see a popup in the page screenshot, prioritize actions on the popup.
+{% endif %}
Reply in JSON format with the following keys:
{
@@ -53,5 +55,5 @@ Reply in JSON format with the following keys:
"should_verify_by_magic_link": bool // Whether the page instructs the user to check their email for a magic link to verify the login.{% endif %}
}
-Consider the action history from the last step and the screenshot together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
-Action history from previous steps: (note: even if the action history suggests goal is achieved, check the screenshot and the DOM elements to make sure the goal is achieved)
+Consider the action history from the last step and the {% if non_vision_page_context %}non-vision page context{% else %}screenshot{% endif %} together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
+Action history from previous steps: (note: even if the action history suggests goal is achieved, check the {% if non_vision_page_context %}non-vision page context{% else %}screenshot{% endif %} and the DOM elements to make sure the goal is achieved)
diff --git a/skyvern/forge/prompts/skyvern/extract-action.j2 b/skyvern/forge/prompts/skyvern/extract-action.j2
index 90b124ec8..f1cdde83f 100644
--- a/skyvern/forge/prompts/skyvern/extract-action.j2
+++ b/skyvern/forge/prompts/skyvern/extract-action.j2
@@ -1,11 +1,13 @@
-Identify actions to help user progress towards the user goal using the DOM elements given in the list and the screenshot of the website.
+Identify actions to help user progress towards the user goal using the DOM elements given in the list{% if non_vision_page_context %}, the non-vision page context, and the accessibility tree of the website{% else %} and the screenshot of the website{% endif %}.
Include only the elements that are relevant to the user goal, without altering or imagining new elements.
Accurately interpret and understand the functional significance of SVG elements based on their shapes and context within the webpage.
Use the user details to fill in necessary values. Always satisfy required fields if the field isn't already filled in. Don't return any action for the same field, if this field is already filled in and the value is the same as the one you would have filled in.
MAKE SURE YOU OUTPUT VALID JSON. No text before or after JSON, no trailing commas, no comments (//), no unnecessary quotes, etc.
Each interactable element is tagged with an ID. Avoid taking action on a disabled element when there is an alternative action available.
-If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
+{% if non_vision_page_context %}If the non-vision page context shows invalid fields, validation messages, error-colored text, dialogs, overlays, or expanded controls, prioritize actions that address those states.
+{% else %}If you see any information in red in the page screenshot, this means a condition wasn't satisfied. prioritize actions with the red information.
If you see a popup in the page screenshot, prioritize actions on the popup.
+{% endif %}
Reply in JSON format with the following keys:
{
@@ -53,8 +55,8 @@ Reply in JSON format with the following keys:
"should_verify_by_magic_link": bool // Whether the page instructs the user to check their email for a magic link to verify the login.{% endif %}
}
-Consider the action history from the last step and the screenshot together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
-Action history from previous steps: (note: even if the action history suggests goal is achieved, check the screenshot and the DOM elements to make sure the goal is achieved)
+Consider the action history from the last step and the {% if non_vision_page_context %}non-vision page context{% else %}screenshot{% endif %} together, if actions from the last step don't yield positive impact, try other actions or other action combinations.
+Action history from previous steps: (note: even if the action history suggests goal is achieved, check the {% if non_vision_page_context %}non-vision page context{% else %}screenshot{% endif %} and the DOM elements to make sure the goal is achieved)
```
{{ action_history }}
```
@@ -97,6 +99,12 @@ Open browser tabs (CLOSE_PAGE always closes the tab marked [current] — other t
{{ open_tabs_context }}
```
{% endif %}
+{% if non_vision_page_context %}
+Non-vision page context and accessibility tree:
+```json
+{{ non_vision_page_context }}
+```
+{% endif %}
Clickable elements from `{{ current_url }}`:
```
{{ elements }}
diff --git a/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2 b/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2
index e0e72fe6c..f039ca032 100644
--- a/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2
+++ b/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2
@@ -70,6 +70,13 @@ If there's a failure, analyze the failure reason and visible elements to provide
No debugger run information available. The workflow hasn't been run yet, or no run data is accessible.
{% endif %}
+{% if repeated_reply_warning is defined and repeated_reply_warning %}
+REPEATED REPLY WARNING:
+
+```
+{{ repeated_reply_warning }}
+```
+{% endif %}
USER MESSAGE:
The user says:
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.py
index 33175fae8..134891d4a 100644
--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py
+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py
@@ -69,6 +69,12 @@ LLM_REQUEST_COMPLETED_EVENT = "llm.request.completed"
EXTRACT_ACTION_PROMPT_NAME = "extract-actions"
CHECK_USER_GOAL_PROMPT_NAMES = {"check-user-goal", "check-user-goal-with-termination"}
+VISION_FALLBACK_PROMPT_NAMES = {
+ "anthropic-cua",
+ "css-shape-convert",
+ "extract-text-from-image",
+ "ui-tars-system-prompt",
+}
# Default thinking budgets (configurable via env vars, can be overridden by THINKING_BUDGET_OPTIMIZATION experiment)
EXTRACT_ACTION_DEFAULT_THINKING_BUDGET = settings.EXTRACT_ACTION_THINKING_BUDGET
@@ -166,14 +172,25 @@ def _llm_screenshots_for_call(
screenshots: list[bytes] | None,
llm_config: LLMConfig | LLMRouterConfig,
context: SkyvernContext | None,
+ prompt_name: str | None = None,
) -> list[bytes] | None:
- if not llm_config.supports_vision or (context and context.disable_llm_screenshots):
+ if not llm_config.supports_vision:
+ return None
+ if context and context.disable_llm_screenshots and prompt_name not in VISION_FALLBACK_PROMPT_NAMES:
return None
return screenshots
-def _llm_screenshots_enabled_metric(llm_config: LLMConfig | LLMRouterConfig, context: SkyvernContext | None) -> bool:
- return llm_config.supports_vision and not bool(context and context.disable_llm_screenshots)
+def _llm_screenshots_enabled_metric(
+ llm_config: LLMConfig | LLMRouterConfig,
+ context: SkyvernContext | None,
+ prompt_name: str | None = None,
+) -> bool:
+ if not llm_config.supports_vision:
+ return False
+ if context and context.disable_llm_screenshots and prompt_name not in VISION_FALLBACK_PROMPT_NAMES:
+ return False
+ return True
@runtime_checkable
@@ -920,8 +937,8 @@ class LLMAPIHandlerFactory:
**artifact_targets,
)
)
- screenshots = _llm_screenshots_for_call(screenshots, llm_config, context)
- llm_screenshots_enabled = _llm_screenshots_enabled_metric(llm_config, context)
+ screenshots = _llm_screenshots_for_call(screenshots, llm_config, context, prompt_name)
+ llm_screenshots_enabled = _llm_screenshots_enabled_metric(llm_config, context, prompt_name)
# Build messages and apply caching in one step
messages = await llm_messages_builder(prompt, screenshots, llm_config.add_assistant_prefix)
@@ -1585,8 +1602,8 @@ class LLMAPIHandlerFactory:
)
)
- screenshots = _llm_screenshots_for_call(screenshots, llm_config, context)
- llm_screenshots_enabled = _llm_screenshots_enabled_metric(llm_config, context)
+ screenshots = _llm_screenshots_for_call(screenshots, llm_config, context, prompt_name)
+ llm_screenshots_enabled = _llm_screenshots_enabled_metric(llm_config, context, prompt_name)
model_name = llm_config.model_name
@@ -2222,8 +2239,8 @@ class LLMCaller:
)
)
- screenshots = _llm_screenshots_for_call(screenshots, self.llm_config, context)
- llm_screenshots_enabled = _llm_screenshots_enabled_metric(self.llm_config, context)
+ screenshots = _llm_screenshots_for_call(screenshots, self.llm_config, context, prompt_name)
+ llm_screenshots_enabled = _llm_screenshots_enabled_metric(self.llm_config, context, prompt_name)
message_pattern = "openai"
if "ANTHROPIC" in self.llm_key:
diff --git a/skyvern/forge/sdk/api/llm/ui_tars_llm_caller.py b/skyvern/forge/sdk/api/llm/ui_tars_llm_caller.py
index 0e6c216e2..54e481236 100644
--- a/skyvern/forge/sdk/api/llm/ui_tars_llm_caller.py
+++ b/skyvern/forge/sdk/api/llm/ui_tars_llm_caller.py
@@ -136,6 +136,7 @@ class UITarsLLMCaller(LLMCaller):
async def generate_ui_tars_response(self, step: Step) -> str:
"""Generate UI-TARS response using the parent LLMCaller directly."""
response = await self.call(
+ prompt_name="ui-tars-system-prompt",
step=step,
use_message_history=True, # Use conversation history
raw_response=True, # Skip JSON parsing for plain text
diff --git a/skyvern/forge/sdk/cache/extraction_cache.py b/skyvern/forge/sdk/cache/extraction_cache.py
index 478db9c59..4bb0e3027 100644
--- a/skyvern/forge/sdk/cache/extraction_cache.py
+++ b/skyvern/forge/sdk/cache/extraction_cache.py
@@ -44,6 +44,8 @@ Key derivation (shared with the cross-run tier):
The prompt is sent to the LLM as the `system` message; changing it
changes the output even if all user-prompt inputs are identical, so two
calls that differ only in workflow_system_prompt must not collide.
+ - non_vision_page_context — rendered only when screenshots are disabled,
+ so screenshot-backed and non-vision-backed prompts do not collide.
- Date is intentionally NOT in the key. Two calls on byte-identical page
content are semantically the same extraction regardless of wall-clock
date; relying on the content hash keeps hit rate up for scheduled
@@ -506,6 +508,7 @@ def compute_cache_key(
previous_extracted_information: Any = None,
llm_key: str | None = None,
workflow_system_prompt: str | None = None,
+ non_vision_page_context: str | None = None,
) -> str:
"""Return a stable sha256 hex digest for the inputs that affect extraction output.
@@ -545,6 +548,7 @@ def compute_cache_key(
_normalize(previous_extracted_information),
_s(llm_key),
_s(workflow_system_prompt),
+ _s(non_vision_page_context),
]
joined = "\x1f".join(parts).encode("utf-8", errors="replace")
return hashlib.sha256(joined).hexdigest()
diff --git a/skyvern/forge/sdk/copilot/agent.py b/skyvern/forge/sdk/copilot/agent.py
index e0596cbe5..2396371ab 100644
--- a/skyvern/forge/sdk/copilot/agent.py
+++ b/skyvern/forge/sdk/copilot/agent.py
@@ -76,8 +76,7 @@ from skyvern.forge.sdk.copilot.turn_intent import (
build_turn_intent,
)
from skyvern.forge.sdk.copilot.turn_outcome import (
- build_minimal_turn_outcome,
- build_turn_outcome,
+ apply_repeated_reply_guard,
derive_response_kind,
)
from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind, TurnOutcome
@@ -342,6 +341,8 @@ def _store_turn_context_packet_on_context(
debug_run_info_text=debug_run_info_text,
)
)
+ if ctx.turn_context_packet.repeated_reply_context is not None:
+ ctx.blocked_reply_signatures = list(ctx.turn_context_packet.repeated_reply_context.blocked_signatures)
def _build_system_prompt(
@@ -409,6 +410,7 @@ def _build_user_context(
user_message: str,
request_policy_summary: str = "",
user_workflow_change_summary: str = "",
+ repeated_reply_warning: str = "",
) -> str:
"""Render untrusted context into the user message with code fencing.
@@ -431,6 +433,7 @@ def _build_user_context(
request_policy_summary=escape_code_fences(redact_raw_secrets_for_prompt(request_policy_summary)),
user_message=escape_code_fences(redact_raw_secrets_for_prompt(user_message)),
user_workflow_change_summary=escape_code_fences(user_workflow_change_summary or ""),
+ repeated_reply_warning=escape_code_fences(repeated_reply_warning or ""),
)
@@ -668,13 +671,14 @@ def _build_exit_result(
) -> AgentResult:
"""AgentResult for agent-loop exits that don't go through ``_translate_to_agent_result``."""
verified_workflow, verified_yaml = _verified_workflow_or_none(ctx)
- outcome = build_minimal_turn_outcome(
- user_response,
- response_kind=ResponseKind.CLARIFY,
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=user_response,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=ctx.blocked_reply_signatures,
terminal_reason=terminal_reason or ("cancel" if cancelled else None),
)
return AgentResult(
- user_response=user_response,
+ user_response=final_text,
updated_workflow=verified_workflow,
global_llm_context=global_llm_context,
workflow_yaml=verified_yaml,
@@ -947,10 +951,11 @@ def _build_wip_exit_result(
recorded_failure_reply = _recorded_failure_reply(ctx, cancelled=cancelled)
effective_terminal = terminal_reason or ("cancel" if cancelled else None)
- def _outcome(text: str) -> TurnOutcome:
- return build_minimal_turn_outcome(
- text,
- response_kind=ResponseKind.CLARIFY,
+ def _guard(text: str) -> tuple[str, TurnOutcome]:
+ return apply_repeated_reply_guard(
+ final_text=text,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=ctx.blocked_reply_signatures,
terminal_reason=effective_terminal,
)
@@ -963,9 +968,9 @@ def _build_wip_exit_result(
and not ctx.last_test_suspicious_success
):
reply = _last_good_failure_reply(ctx, tested_reply) if recorded_failure_reply else tested_reply
- outcome = _outcome(reply)
+ final_text, outcome = _guard(reply)
return AgentResult(
- user_response=reply,
+ user_response=final_text,
updated_workflow=ctx.last_good_workflow,
global_llm_context=global_llm_context,
workflow_yaml=ctx.last_good_workflow_yaml,
@@ -986,9 +991,9 @@ def _build_wip_exit_result(
reply = recorded_failure_reply
else:
reply = unvalidated_reply if unvalidated else tested_reply
- outcome = _outcome(reply)
+ final_text, outcome = _guard(reply)
return AgentResult(
- user_response=reply,
+ user_response=final_text,
updated_workflow=ctx.last_workflow,
global_llm_context=global_llm_context,
workflow_yaml=ctx.last_workflow_yaml,
@@ -1367,11 +1372,12 @@ def _translate_to_agent_result(
)
reason_code = ",".join(reason_codes)
- turn_outcome = build_turn_outcome(
- final_user_response,
- turn_intent=ctx.turn_intent,
- response_kind=attempted_kind,
+ final_user_response, turn_outcome = apply_repeated_reply_guard(
+ final_text=final_user_response,
+ attempted_kind=attempted_kind,
+ blocked_signatures=ctx.blocked_reply_signatures,
reason_code=reason_code,
+ turn_intent=ctx.turn_intent,
tool_calls=[name for name in tool_call_names if name],
)
@@ -1402,6 +1408,7 @@ def _build_feasibility_clarification_result(
user_message: str,
prior_global_llm_context: str | None,
prior_workflow_yaml: str | None,
+ ctx: CopilotContext,
) -> AgentResult:
"""Construct an AgentResult for the feasibility-gate fast-path.
@@ -1417,19 +1424,21 @@ def _build_feasibility_clarification_result(
structured.decisions_made.append(f"feasibility-gate clarification asked: {question}")
enriched_context = structured.to_json_str()
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=question,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=list(ctx.blocked_reply_signatures),
+ reason_code="feasibility_clarification",
+ )
return AgentResult(
- user_response=question,
+ user_response=final_text,
updated_workflow=None,
global_llm_context=enriched_context,
response_type="ASK_QUESTION",
workflow_yaml=prior_workflow_yaml or None,
workflow_was_persisted=False,
clear_proposed_workflow=True,
- turn_outcome=build_minimal_turn_outcome(
- question,
- response_kind=ResponseKind.CLARIFY,
- reason_code="feasibility_clarification",
- ),
+ turn_outcome=outcome,
)
@@ -1482,6 +1491,7 @@ def _build_request_policy_clarification_result(
policy: RequestPolicy,
prior_global_llm_context: str | None,
prior_workflow_yaml: str | None,
+ ctx: CopilotContext,
) -> AgentResult:
structured = StructuredContext.from_json_str(prior_global_llm_context)
structured.decisions_made.append(
@@ -1490,19 +1500,21 @@ def _build_request_policy_clarification_result(
clarification_text = (
policy.clarification_question or "I need one more detail before I can build and test this workflow safely."
)
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=clarification_text,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=list(ctx.blocked_reply_signatures),
+ reason_code="request_policy_clarification",
+ )
return AgentResult(
- user_response=clarification_text,
+ user_response=final_text,
updated_workflow=None,
global_llm_context=structured.to_json_str(),
response_type="ASK_QUESTION",
workflow_yaml=prior_workflow_yaml or None,
workflow_was_persisted=False,
clear_proposed_workflow=True,
- turn_outcome=build_minimal_turn_outcome(
- clarification_text,
- response_kind=ResponseKind.CLARIFY,
- reason_code="request_policy_clarification",
- ),
+ turn_outcome=outcome,
)
@@ -1782,14 +1794,15 @@ def _build_output_policy_blocked_result(
user_response = "I could not safely return that chat reply. Please adjust the request and try again."
if preserved_workflow is not None and add_saved_draft_copy:
user_response = f"{user_response} {_SAVED_DRAFT_OUTPUT_POLICY_SUFFIX}"
- output_policy_outcome = build_minimal_turn_outcome(
- user_response,
- response_kind=ResponseKind.CLARIFY,
+ final_user_response, output_policy_outcome = apply_repeated_reply_guard(
+ final_text=user_response,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=ctx.blocked_reply_signatures,
reason_code="output_policy_block",
terminal_reason="output_policy_block",
)
return AgentResult(
- user_response=user_response,
+ user_response=final_user_response,
updated_workflow=preserved_workflow,
global_llm_context=structured.to_json_str(),
response_type="ASK_QUESTION",
@@ -1939,13 +1952,16 @@ async def _run_copilot_turn_impl(
"Copilot backend is missing the OpenAI Agents SDK dependency. "
"Rebuild or redeploy the backend image so `openai-agents` is installed."
)
- missing_sdk_outcome = build_minimal_turn_outcome(
- missing_sdk_reply,
- response_kind=ResponseKind.CLARIFY,
+ # ctx isn't constructed yet at this exit (deploy-state check fires
+ # before CopilotContext allocation), so no inherited bans to thread.
+ final_missing_text, missing_sdk_outcome = apply_repeated_reply_guard(
+ final_text=missing_sdk_reply,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=(),
terminal_reason="missing_sdk",
)
return AgentResult(
- user_response=missing_sdk_reply,
+ user_response=final_missing_text,
updated_workflow=None,
global_llm_context=global_llm_context,
workflow_yaml=chat_request.workflow_yaml or None,
@@ -2007,6 +2023,7 @@ async def _run_copilot_turn_impl(
request_policy,
prior_global_llm_context=global_llm_context,
prior_workflow_yaml=chat_request.workflow_yaml,
+ ctx=ctx,
)
if request_policy is None:
raise CopilotRequestPolicyMissingError()
@@ -2036,6 +2053,7 @@ async def _run_copilot_turn_impl(
user_message=agent_user_message,
prior_global_llm_context=global_llm_context,
prior_workflow_yaml=chat_request.workflow_yaml,
+ ctx=ctx,
)
from skyvern.cli.mcp_tools import mcp as skyvern_mcp
@@ -2082,11 +2100,12 @@ async def _run_copilot_turn_impl(
)
user_workflow_change_summary = ""
- if (
- isinstance(ctx.turn_context_packet, TurnContextPacket)
- and ctx.turn_context_packet.workflow_change_context is not None
- ):
- user_workflow_change_summary = ctx.turn_context_packet.workflow_change_context.rendered_summary
+ repeated_reply_warning = ""
+ if isinstance(ctx.turn_context_packet, TurnContextPacket):
+ if ctx.turn_context_packet.workflow_change_context is not None:
+ user_workflow_change_summary = ctx.turn_context_packet.workflow_change_context.rendered_summary
+ if ctx.turn_context_packet.repeated_reply_context is not None:
+ repeated_reply_warning = ctx.turn_context_packet.repeated_reply_context.rendered_summary
user_message = _build_user_context(
workflow_yaml=safe_workflow_yaml,
@@ -2095,6 +2114,7 @@ async def _run_copilot_turn_impl(
debug_run_info_text=redact_raw_secrets_for_prompt(debug_run_info_text),
user_message=agent_user_message,
user_workflow_change_summary=user_workflow_change_summary,
+ repeated_reply_warning=repeated_reply_warning,
)
LOG.info(
@@ -2223,6 +2243,7 @@ async def _run_copilot_turn_impl(
request_policy,
prior_global_llm_context=global_llm_context,
prior_workflow_yaml=chat_request.workflow_yaml,
+ ctx=ctx,
)
except OutputGuardrailTripwireTriggered as exc:
return _build_output_policy_blocked_result(
@@ -2257,13 +2278,14 @@ async def _run_copilot_turn_impl(
f"The target URL could not be reached. Error: {exc.error_message}. "
"Please verify the URL and try again."
)
- nav_outcome = build_minimal_turn_outcome(
- nav_reply,
- response_kind=ResponseKind.CLARIFY,
+ final_nav_text, nav_outcome = apply_repeated_reply_guard(
+ final_text=nav_reply,
+ attempted_kind=ResponseKind.CLARIFY,
+ blocked_signatures=ctx.blocked_reply_signatures,
terminal_reason="non_retriable_nav",
)
return AgentResult(
- user_response=nav_reply,
+ user_response=final_nav_text,
updated_workflow=None,
global_llm_context=global_llm_context,
workflow_yaml=None,
diff --git a/skyvern/forge/sdk/copilot/context.py b/skyvern/forge/sdk/copilot/context.py
index 079ce36f3..0834ad083 100644
--- a/skyvern/forge/sdk/copilot/context.py
+++ b/skyvern/forge/sdk/copilot/context.py
@@ -177,6 +177,7 @@ class CopilotContext(AgentContext):
turn_intent: TurnIntent | None = None
turn_context_packet: TurnContextPacket | None = None
latest_diagnosis_repair_contract: DiagnosisRepairContract | None = None
+ blocked_reply_signatures: list[str] = field(default_factory=list)
# Tool tracking
consecutive_tool_tracker: list[str] = field(default_factory=list)
diff --git a/skyvern/forge/sdk/copilot/repeated_reply_summary.py b/skyvern/forge/sdk/copilot/repeated_reply_summary.py
new file mode 100644
index 000000000..bcf47486c
--- /dev/null
+++ b/skyvern/forge/sdk/copilot/repeated_reply_summary.py
@@ -0,0 +1,134 @@
+"""Typed signal: is the copilot looping on the same answer?
+
+Reads persisted ``TurnOutcome`` rows from the last assistant turns plus the
+current ``TurnIntent``'s ``USER_NON_PROGRESS`` reason code, and emits a ban
+set of normalized signatures. The prompt block surfaces the ban; the
+enforcement guard in ``_translate_to_agent_result`` blocks a re-emission of
+any signature in the set.
+
+Why TurnIntent owns the "user is on the same problem" signal: the
+M1.5 architecture decision is that classifiers emit typed intent/reason
+codes and deterministic resolvers consume them — duplicating a semantic
+regex here would be the "distributed-intent" anti-pattern.
+
+Durability: a signature stays banned across turns as long as TurnIntent
+keeps emitting ``USER_NON_PROGRESS``. A topic switch (classifier drops the
+code) unfreezes the inherited set. A timeout / error / cancel interruption
+does not unfreeze it — inherited bans carry through intermediate
+``CLARIFY``-terminal outcomes.
+"""
+
+from __future__ import annotations
+
+from dataclasses import dataclass
+from enum import Enum
+
+from skyvern.forge.sdk.copilot.turn_intent import TurnIntent, TurnIntentReasonCode
+from skyvern.forge.sdk.schemas.copilot_turn_outcome import TurnOutcome
+from skyvern.forge.sdk.schemas.workflow_copilot import WorkflowCopilotChatHistoryMessage, WorkflowCopilotChatSender
+
+# Fresh-trip detection needs exactly 2 consecutive assistant turns with the
+# same (response_kind, signature); older bans carry forward through the
+# inherited blocked_signatures union, so widening the window is unnecessary.
+_RECENT_OUTCOME_WINDOW = 2
+
+
+class RepeatedReplyKind(str, Enum):
+ NO_REPEAT = "no_repeat"
+ REPEATED_REPLY_DETECTED = "repeated_reply_detected"
+
+
+@dataclass(frozen=True)
+class RepeatedReplySummary:
+ kind: RepeatedReplyKind
+ blocked_signatures: tuple[str, ...] = ()
+ repeat_count: int = 0
+
+ def render_prompt_block(self) -> str:
+ if self.kind is not RepeatedReplyKind.REPEATED_REPLY_DETECTED:
+ return ""
+ sig_list = ", ".join(self.blocked_signatures) if self.blocked_signatures else "(none)"
+ return (
+ "repeated_reply_detected: your last replies in this conversation"
+ " repeated the same normalized signature and the user is still"
+ f" signaling non-progress. Blocked signatures: {sig_list}. Do not"
+ " produce a reply whose normalized signature matches one of these."
+ " Change approach: give a concretely different explanation, take a"
+ " different action, surface the limitation honestly, or hand off."
+ )
+
+
+def _recent_assistant_outcomes(
+ chat_history: list[WorkflowCopilotChatHistoryMessage],
+) -> list[TurnOutcome | None]:
+ outcomes: list[TurnOutcome | None] = []
+ for message in reversed(chat_history):
+ if message.sender != WorkflowCopilotChatSender.AI:
+ continue
+ if not (message.content or "").strip():
+ continue
+ outcomes.append(message.turn_outcome)
+ if len(outcomes) >= _RECENT_OUTCOME_WINDOW:
+ break
+ return outcomes
+
+
+def _inherited_block_set(outcomes: list[TurnOutcome | None]) -> set[str]:
+ inherited: set[str] = set()
+ for outcome in outcomes:
+ if outcome is None:
+ continue
+ inherited.update(sig for sig in outcome.blocked_signatures if sig)
+ return inherited
+
+
+def _fresh_trip_signature(outcomes: list[TurnOutcome | None]) -> str | None:
+ if len(outcomes) < _RECENT_OUTCOME_WINDOW:
+ return None
+ first, second = outcomes[0], outcomes[1]
+ if first is None or second is None:
+ return None
+ if (
+ first.response_kind == second.response_kind
+ and first.normalized_reply_signature == second.normalized_reply_signature
+ and first.normalized_reply_signature
+ ):
+ return first.normalized_reply_signature
+ return None
+
+
+def _user_on_same_problem(turn_intent: TurnIntent | None) -> bool:
+ if turn_intent is None:
+ return False
+ return TurnIntentReasonCode.USER_NON_PROGRESS in turn_intent.reason_codes
+
+
+def summarize_repeated_replies(
+ chat_history: list[WorkflowCopilotChatHistoryMessage],
+ turn_intent: TurnIntent | None,
+) -> RepeatedReplySummary:
+ if not chat_history:
+ return RepeatedReplySummary(kind=RepeatedReplyKind.NO_REPEAT)
+
+ if not _user_on_same_problem(turn_intent):
+ return RepeatedReplySummary(kind=RepeatedReplyKind.NO_REPEAT)
+
+ outcomes = _recent_assistant_outcomes(chat_history)
+ block_set = _inherited_block_set(outcomes)
+ fresh = _fresh_trip_signature(outcomes)
+ if fresh is not None:
+ block_set.add(fresh)
+
+ if not block_set:
+ return RepeatedReplySummary(kind=RepeatedReplyKind.NO_REPEAT)
+
+ blocked = tuple(sorted(block_set))
+ repeat_count = sum(
+ 1 for outcome in outcomes if outcome is not None and outcome.normalized_reply_signature in block_set
+ )
+ repeat_count = max(repeat_count, 2) if fresh is not None else max(repeat_count, 1)
+ return RepeatedReplySummary(
+ kind=RepeatedReplyKind.REPEATED_REPLY_DETECTED,
+ blocked_signatures=blocked,
+ repeat_count=repeat_count,
+ )
diff --git a/skyvern/forge/sdk/copilot/turn_context.py b/skyvern/forge/sdk/copilot/turn_context.py
index 90bc99a8e..856f75258 100644
--- a/skyvern/forge/sdk/copilot/turn_context.py
+++ b/skyvern/forge/sdk/copilot/turn_context.py
@@ -5,6 +5,7 @@ from typing import Any, Literal
import structlog
from pydantic import BaseModel, ConfigDict, Field
+from skyvern.forge.sdk.copilot.repeated_reply_summary import RepeatedReplyKind, summarize_repeated_replies
from skyvern.forge.sdk.copilot.request_policy import (
RequestPolicy,
build_transcript_context,
@@ -53,6 +54,13 @@ class WorkflowChangeContext(BaseModel):
structural_diff_unavailable: bool = False
+class RepeatedReplyContext(BaseModel):
+ kind: RepeatedReplyKind
+ rendered_summary: str
+ repeat_count: int
+ blocked_signatures: list[str] = Field(default_factory=list)
+
+
class TranscriptContext(BaseModel):
earliest_user_turn: str
latest_prior_user_turn: str
@@ -97,6 +105,7 @@ class TurnContextPacket(BaseModel):
run_context: RunContext | None = None
credential_context: CredentialContext | None = None
docs_context: DocsContext | None = None
+ repeated_reply_context: RepeatedReplyContext | None = None
omissions: list[TurnContextOmission] = Field(default_factory=list)
def to_trace_data(self) -> dict[str, Any]:
@@ -107,6 +116,7 @@ class TurnContextPacket(BaseModel):
"run_context",
"credential_context",
"docs_context",
+ "repeated_reply_context",
)
return {
"mode": self.turn_intent_summary.get("mode"),
@@ -117,6 +127,8 @@ class TurnContextPacket(BaseModel):
"proposal_truncated": bool(self.proposal_context and self.proposal_context.truncated),
"run_truncated": bool(self.run_context and self.run_context.truncated),
"workflow_change_kind": self.workflow_change_context.kind if self.workflow_change_context else None,
+ "repeated_reply_kind": self.repeated_reply_context.kind.value if self.repeated_reply_context else None,
+ "repeated_reply_count": self.repeated_reply_context.repeat_count if self.repeated_reply_context else 0,
}
@@ -287,6 +299,16 @@ class TurnContextAssembler:
if RequiredContextKey.DOCS_CONTEXT in required:
docs_context = DocsContext()
+ repeated_reply_context: RepeatedReplyContext | None = None
+ repeated_reply = summarize_repeated_replies(inputs.chat_history, inputs.turn_intent)
+ if repeated_reply.kind is RepeatedReplyKind.REPEATED_REPLY_DETECTED:
+ repeated_reply_context = RepeatedReplyContext(
+ kind=repeated_reply.kind,
+ rendered_summary=repeated_reply.render_prompt_block(),
+ repeat_count=repeated_reply.repeat_count,
+ blocked_signatures=list(repeated_reply.blocked_signatures),
+ )
+
if RequiredContextKey.BROWSER_STATE in required:
omissions.append(
TurnContextOmission(
@@ -305,6 +327,7 @@ class TurnContextAssembler:
run_context=run_context,
credential_context=credential_context,
docs_context=docs_context,
+ repeated_reply_context=repeated_reply_context,
omissions=omissions,
)
diff --git a/skyvern/forge/sdk/copilot/turn_outcome.py b/skyvern/forge/sdk/copilot/turn_outcome.py
index c9b970678..0ff906c16 100644
--- a/skyvern/forge/sdk/copilot/turn_outcome.py
+++ b/skyvern/forge/sdk/copilot/turn_outcome.py
@@ -19,6 +19,118 @@ from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind, TurnOut
LOG = structlog.get_logger()
+IDENTICAL_REPLY_BLOCKED_TERMINAL_REASON = "identical_reply_blocked"
+
+REPEATED_REPLY_ESCALATION_TEMPLATES: dict[ResponseKind, str] = {
+ ResponseKind.BUILD: (
+ "I've offered the same change twice and it isn't moving us forward."
+ " Tell me one concrete edit you want to make to the workflow"
+ " (e.g. a step to add, a page to open, a field to extract) and I'll"
+ " build that exact thing."
+ ),
+ ResponseKind.CLARIFY: (
+ "I've asked the same clarification twice. Let me try a different"
+ " angle — please confirm the single next concrete step you'd like me"
+ " to take, and I'll act on that."
+ ),
+ ResponseKind.DIAGNOSE: (
+ "I've explained that the same way twice. Either the explanation"
+ " isn't matching what you're seeing, or I'm missing context — could"
+ " you share what you actually see, or paste the exact error, so I can"
+ " try a different angle?"
+ ),
+ ResponseKind.REFUSE: (
+ "I've refused that the same way twice. If you want me to reconsider,"
+ " tell me what's different about this case and I'll re-evaluate."
+ ),
+}
+
+
+HANDOFF_REPLY = (
+ "I haven't been able to help with this through repeated attempts. Please"
+ " rephrase the request with more specifics, or use the Help link so a"
+ " teammate can take a closer look."
+)
+
+
+def escalation_reply_for(attempted_kind: ResponseKind) -> str:
+ return REPEATED_REPLY_ESCALATION_TEMPLATES.get(
+ attempted_kind, REPEATED_REPLY_ESCALATION_TEMPLATES[ResponseKind.CLARIFY]
+ )
+
+
+def apply_repeated_reply_guard(
+ *,
+ final_text: str,
+ attempted_kind: ResponseKind,
+ blocked_signatures: Iterable[str],
+ reason_code: str = "",
+ terminal_reason: str | None = None,
+ turn_intent: TurnIntent | None = None,
+ tool_calls: Iterable[str] = (),
+) -> tuple[str, TurnOutcome]:
+ """Centralized post-output guard. Returns ``(final_text, outcome)``.
+
+ When the signature of ``final_text`` is in ``blocked_signatures``, rewrites
+ to the escalation template keyed by ``attempted_kind`` and returns a
+ ``RECOVER`` outcome that records the original signature in its
+ ``blocked_signatures`` so the ban survives to the next turn. If the
+ escalation template itself collides with an already-banned signature
+ (a back-to-back ``RECOVER`` loop), falls back to a generic hand-off so
+ the system cannot self-amplify on the same recovery text. Otherwise
+ returns the original text with a record carrying the inherited bans
+ forward. The rewritten signature is also added to ``blocked_signatures``
+ so a future turn cannot re-emit the same escalation text.
+
+ Pass ``turn_intent`` and ``tool_calls`` to preserve trace metadata on
+ the outcome; otherwise the minimal-shape builder is used.
+ """
+ inherited = list(blocked_signatures)
+ tool_calls_list = list(tool_calls)
+ original_signature = compute_signature(final_text)
+ if inherited and original_signature in inherited:
+ rewritten = escalation_reply_for(attempted_kind)
+ rewritten_signature = compute_signature(rewritten)
+ if rewritten_signature in inherited:
+ rewritten = HANDOFF_REPLY
+ rewritten_signature = compute_signature(rewritten)
+ intent_summary: dict[str, Any] = {}
+ if turn_intent is not None:
+ try:
+ intent_summary = dict(turn_intent.to_trace_data())
+ except Exception as exc:
+ LOG.warning(
+ "Failed to serialize TurnIntent trace data for RECOVER outcome; using empty dict",
+ exc_info=exc,
+ )
+ return rewritten, TurnOutcome(
+ turn_intent_summary=intent_summary,
+ response_kind=ResponseKind.RECOVER,
+ reason_code=IDENTICAL_REPLY_BLOCKED_TERMINAL_REASON,
+ normalized_reply_signature=rewritten_signature,
+ tool_calls=[str(c) for c in tool_calls_list if c],
+ terminal_reason=IDENTICAL_REPLY_BLOCKED_TERMINAL_REASON,
+ blocked_signatures=_dedup_signatures([*inherited, original_signature, rewritten_signature]),
+ )
+ if turn_intent is not None or tool_calls_list:
+ return final_text, build_turn_outcome(
+ final_text,
+ turn_intent=turn_intent,
+ response_kind=attempted_kind,
+ reason_code=reason_code,
+ tool_calls=tool_calls_list,
+ terminal_reason=terminal_reason,
+ inherited_blocked_signatures=inherited,
+ )
+ return final_text, build_minimal_turn_outcome(
+ final_text,
+ response_kind=attempted_kind,
+ reason_code=reason_code,
+ terminal_reason=terminal_reason,
+ inherited_blocked_signatures=inherited,
+ )
+
+
_RESPONSE_KIND_BY_MODE: dict[TurnIntentMode, ResponseKind] = {
TurnIntentMode.BUILD: ResponseKind.BUILD,
TurnIntentMode.EDIT: ResponseKind.BUILD,
diff --git a/skyvern/forge/sdk/prompting.py b/skyvern/forge/sdk/prompting.py
index fd3347206..c97569ca9 100644
--- a/skyvern/forge/sdk/prompting.py
+++ b/skyvern/forge/sdk/prompting.py
@@ -31,6 +31,15 @@ from skyvern.constants import SKYVERN_DIR
LOG = structlog.get_logger()
+NON_VISION_CONTEXT_HEADER = "Non-vision page context and accessibility tree:"
+
+
+def _with_non_vision_context(prompt: str, template: str, kwargs: dict[str, Any]) -> str:
+ non_vision_page_context = kwargs.get("non_vision_page_context")
+ if not non_vision_page_context or template.endswith("-static") or NON_VISION_CONTEXT_HEADER in prompt:
+ return prompt
+ return f"{prompt.rstrip()}\n\n{NON_VISION_CONTEXT_HEADER}\n```json\n{non_vision_page_context}\n```"
+
class PromptEngine:
"""
@@ -100,7 +109,7 @@ class PromptEngine:
try:
template = "/".join([self.model, template])
jinja_template = self.env.get_template(f"{template}.j2")
- return jinja_template.render(**kwargs)
+ return _with_non_vision_context(jinja_template.render(**kwargs), template, kwargs)
except Exception:
LOG.error(
"Failed to load prompt.",
@@ -123,7 +132,7 @@ class PromptEngine:
"""
try:
jinja_template = self.env.from_string(template)
- return jinja_template.render(**kwargs)
+ return _with_non_vision_context(jinja_template.render(**kwargs), template, kwargs)
except Exception:
LOG.error(
"Failed to load prompt from string.",
diff --git a/skyvern/schemas/docs/doc_strings.py b/skyvern/schemas/docs/doc_strings.py
index c4798da1e..b9c775c8e 100644
--- a/skyvern/schemas/docs/doc_strings.py
+++ b/skyvern/schemas/docs/doc_strings.py
@@ -7,7 +7,7 @@ The starting URL for the task. If not provided, Skyvern will attempt to determin
"""
TASK_ENGINE_DOC_STRING = """
-The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
+The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` remains available for existing V2 workflows and explicitly requested V2 task runs. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.
"""
PROXY_LOCATION_DOC_STRING = """
diff --git a/skyvern/schemas/runs.py b/skyvern/schemas/runs.py
index b8f4dcd64..bb2e80d21 100644
--- a/skyvern/schemas/runs.py
+++ b/skyvern/schemas/runs.py
@@ -143,7 +143,12 @@ class TaskRunRequest(BaseModel):
)
publish_workflow: bool = Field(
default=False,
- description="Whether to publish this task as a reusable workflow. Only available for skyvern-2.0.",
+ description=(
+ "Deprecated. Whether to publish a `skyvern-2.0` task as a reusable workflow. "
+ "For backwards compatibility, this routes the request through the legacy `skyvern-2.0` "
+ "publish path. Prefer creating reusable workflows through the workflow APIs."
+ ),
+ json_schema_extra={"deprecated": True},
)
include_action_history_in_verification: bool | None = Field(
default=False, description="Whether to include action history when verifying that the task is complete"
@@ -192,7 +197,7 @@ class TaskRunRequest(BaseModel):
return mask_header_values(headers)
@model_validator(mode="after")
- def _force_v2_for_publish_workflow(self) -> TaskRunRequest:
+ def _route_publish_workflow_to_v2(self) -> TaskRunRequest:
if self.publish_workflow and self.engine != RunEngine.skyvern_v2:
self.engine = RunEngine.skyvern_v2
return self
diff --git a/skyvern/services/script_service.py b/skyvern/services/script_service.py
index e2dc98007..aaf0564d3 100644
--- a/skyvern/services/script_service.py
+++ b/skyvern/services/script_service.py
@@ -92,6 +92,7 @@ from skyvern.schemas.workflows import BlockResult, BlockStatus, BlockType, FileS
from skyvern.utils.css_selector import build_action_summaries_with_timing
from skyvern.webeye.actions.action_types import ActionType
from skyvern.webeye.actions.actions import Action, DecisiveAction
+from skyvern.webeye.scraper.non_vision_context import build_non_vision_page_context_if_needed
from skyvern.webeye.scraper.scraped_page import ElementTreeFormat
LOG = structlog.get_logger()
@@ -1097,6 +1098,7 @@ async def _detect_user_defined_errors(
action_history=[],
local_datetime=datetime.now(tz_info).isoformat(),
reasoning=None,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(scraped_page=scraped_page),
)
# Call LLM to detect errors
diff --git a/skyvern/services/task_v2_service.py b/skyvern/services/task_v2_service.py
index ec9fa2e9b..209a80c27 100644
--- a/skyvern/services/task_v2_service.py
+++ b/skyvern/services/task_v2_service.py
@@ -69,6 +69,7 @@ from skyvern.services.webhook_delivery import deliver_webhook_with_retries
from skyvern.utils.prompt_engine import load_prompt_with_elements
from skyvern.utils.strings import generate_random_string
from skyvern.webeye.browser_state import BrowserState
+from skyvern.webeye.scraper.non_vision_context import build_non_vision_page_context_if_needed
from skyvern.webeye.scraper.scraped_page import ScrapedPage
from skyvern.webeye.utils.page import SkyvernFrame
@@ -139,6 +140,7 @@ async def _summarize_max_steps_failure_reason(
navigation_goal=task_v2.prompt,
history=history,
local_datetime=datetime.now(context.tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(page=page),
)
json_response = await app.LLM_API_HANDLER(
@@ -821,6 +823,10 @@ async def run_task_v2_helper(
user_goal=user_prompt,
task_history=task_history,
local_datetime=datetime.now(context.tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page,
+ page=page,
+ ),
)
thought = await app.DATABASE.observer.create_thought(
task_v2_id=task_v2_id,
@@ -883,6 +889,10 @@ async def run_task_v2_helper(
task_history=task_history,
context=context,
screenshots=scraped_page.screenshots,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page,
+ page=page,
+ ),
)
if task_v2.run_with == "code":
await app.WORKFLOW_SERVICE.generate_script_if_needed(
@@ -1053,6 +1063,7 @@ async def run_task_v2_helper(
break
if block_result.success is True:
completion_screenshots = []
+ completion_scraped_page: ScrapedPage | None = None
try:
browser_state = await app.BROWSER_MANAGER.get_or_create_for_workflow_run(
workflow_run=workflow_run,
@@ -1060,12 +1071,12 @@ async def run_task_v2_helper(
browser_session_id=browser_session_id,
browser_profile_id=workflow_run.browser_profile_id,
)
- scraped_page = await browser_state.scrape_website(
+ completion_scraped_page = await browser_state.scrape_website(
url=url,
cleanup_element_tree=app.AGENT_FUNCTION.cleanup_element_tree_factory(),
scrape_exclude=app.scrape_exclude,
)
- completion_screenshots = scraped_page.screenshots
+ completion_screenshots = completion_scraped_page.screenshots
except Exception:
LOG.warning("Failed to scrape the website for task v2 completion check")
@@ -1075,6 +1086,9 @@ async def run_task_v2_helper(
user_goal=user_prompt,
task_history=task_history,
local_datetime=datetime.now(context.tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=completion_scraped_page
+ ),
)
thought = await app.DATABASE.observer.create_thought(
task_v2_id=task_v2_id,
@@ -1126,6 +1140,9 @@ async def run_task_v2_helper(
task_history=task_history,
context=context,
screenshots=completion_screenshots,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=completion_scraped_page
+ ),
)
if task_v2.run_with == "code":
await app.WORKFLOW_SERVICE.generate_script_if_needed(
@@ -1462,6 +1479,7 @@ async def _generate_loop_task(
local_datetime=datetime.now(context.tz_info).isoformat(),
is_link=is_loop_value_link,
loop_values=loop_values,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(scraped_page=scraped_page),
)
thought_task_in_loop = await app.DATABASE.observer.create_thought(
task_v2_id=task_v2.observer_cruise_id,
@@ -1572,6 +1590,7 @@ async def _generate_extraction_task(
current_url=current_url,
data_extraction_goal=data_extraction_goal,
local_datetime=datetime.now(context.tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(scraped_page=scraped_page),
)
max_retries = 3
@@ -1962,6 +1981,7 @@ async def _summarize_task_v2(
task_history: list[dict],
context: SkyvernContext,
screenshots: list[bytes] | None = None,
+ non_vision_page_context: str | None = None,
) -> TaskV2:
thought = await app.DATABASE.observer.create_thought(
task_v2_id=task_v2.observer_cruise_id,
@@ -1979,6 +1999,7 @@ async def _summarize_task_v2(
task_history=task_history,
extracted_information_schema=task_v2.extracted_information_schema,
local_datetime=datetime.now(context.tz_info).isoformat(),
+ non_vision_page_context=non_vision_page_context,
)
task_v2_summary_resp = await app.LLM_API_HANDLER(
prompt=task_v2_summary_prompt,
diff --git a/skyvern/utils/prompt_engine.py b/skyvern/utils/prompt_engine.py
index 71c7e8ef6..0c265a0ca 100644
--- a/skyvern/utils/prompt_engine.py
+++ b/skyvern/utils/prompt_engine.py
@@ -50,11 +50,12 @@ CEILING_FALLBACK_KEYS_BY_TEMPLATE: dict[str, list[str]] = {
"previous_extracted_information",
"extracted_information_schema",
"extracted_text",
+ "non_vision_page_context",
],
- "extract-action": ["action_history", "navigation_payload_str"],
- "extract-action-dynamic": ["action_history", "navigation_payload_str"],
+ "extract-action": ["action_history", "navigation_payload_str", "non_vision_page_context"],
+ "extract-action-dynamic": ["action_history", "navigation_payload_str", "non_vision_page_context"],
"extract-action-static": [],
- "data-extraction-summary": ["data_extraction_schema"],
+ "data-extraction-summary": ["data_extraction_schema", "non_vision_page_context"],
}
diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py
index b08330d1b..676a9c1b9 100644
--- a/skyvern/webeye/actions/handler.py
+++ b/skyvern/webeye/actions/handler.py
@@ -120,6 +120,7 @@ from skyvern.webeye.cdp_download_interceptor import (
is_download_response,
normalize_download_filename,
)
+from skyvern.webeye.scraper.non_vision_context import build_non_vision_page_context_if_needed
from skyvern.webeye.scraper.scraped_page import (
CleanupElementTreeFunc,
ElementTreeBuilder,
@@ -1395,6 +1396,10 @@ async def handle_sequential_click_for_dropdown(
without_screenshots=True,
action_history=action_history_str,
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page_after_open,
+ page=page,
+ ),
lean_compress_long_href=lean_enabled,
lean_compress_image_src=lean_enabled,
lean_strip_url_query_strings=lean_enabled,
@@ -1432,25 +1437,13 @@ async def handle_sequential_click_for_dropdown(
step=step,
)
- options = CustomSelectPromptOptions(
- field_information=dropdown_select_context.intention
- if dropdown_select_context.intention
- else dropdown_select_context.field,
- is_date_related=dropdown_select_context.is_date_related,
- required_field=dropdown_select_context.is_required,
- )
-
if dropdown_select_context.is_date_related:
- return await _select_date_from_emerging_elements_or_skip(
- current_element_id=anchor_element.get_id(),
- options=options,
- page=page,
- scraped_page=scraped_page,
- step=step,
- task=task,
- scraped_page_after_open=scraped_page_after_open,
- new_interactable_element_ids=new_interactable_element_ids,
+ LOG.info(
+ "The dropdown is date related, exiting the sequential click logic and skipping the remaining actions",
)
+ result = ActionSuccess()
+ result.skip_remaining_actions = True
+ return result
LOG.info(
"Found the dropdown menu element after clicking, triggering the sequential click logic",
@@ -1459,7 +1452,13 @@ async def handle_sequential_click_for_dropdown(
return await select_from_emerging_elements(
current_element_id=anchor_element.get_id(),
- options=options,
+ options=CustomSelectPromptOptions(
+ field_information=dropdown_select_context.intention
+ if dropdown_select_context.intention
+ else dropdown_select_context.field,
+ is_date_related=dropdown_select_context.is_date_related,
+ required_field=dropdown_select_context.is_required,
+ ),
page=page,
scraped_page=scraped_page,
step=step,
@@ -4124,6 +4123,7 @@ async def sequentially_select_from_dropdown(
elements="".join(json_to_html(element) for element in secondary_increment_element),
select_history=json.dumps(build_sequential_select_history(select_history)),
local_datetime=datetime.now(ensure_context().tz_info).isoformat(),
+ non_vision_page_context=await build_non_vision_page_context_if_needed(page=page),
)
llm_api_handler = LLMAPIHandlerFactory.get_override_llm_api_handler(task.llm_key, default=app.LLM_API_HANDLER)
json_response = await llm_api_handler(
@@ -4183,49 +4183,6 @@ class CustomSelectPromptOptions(BaseModel):
target_value: str | None = None
-async def _select_date_from_emerging_elements_or_skip(
- current_element_id: str,
- options: CustomSelectPromptOptions,
- page: Page,
- scraped_page: ScrapedPage,
- step: Step,
- task: Task,
- scraped_page_after_open: ScrapedPage,
- new_interactable_element_ids: list[str],
-) -> ActionResult:
- try:
- result = await select_from_emerging_elements(
- current_element_id=current_element_id,
- options=options,
- page=page,
- scraped_page=scraped_page,
- step=step,
- task=task,
- scraped_page_after_open=scraped_page_after_open,
- new_interactable_element_ids=new_interactable_element_ids,
- )
- except Exception:
- LOG.warning(
- "Date-related emerging element selection failed, preserving skip behavior",
- current_element_id=current_element_id,
- exc_info=True,
- )
- result = ActionSuccess()
-
- if not result.success:
- LOG.warning(
- "Date-related emerging element selection returned failure, preserving skip behavior",
- current_element_id=current_element_id,
- selection_exception_type=result.exception_type,
- selection_exception_message=result.exception_message,
- selection_data=result.data,
- )
- result = ActionSuccess()
-
- result.skip_remaining_actions = True
- return result
-
-
def _extract_new_subtrees(elements: list[dict], new_ids: set[str]) -> list[dict]:
"""Walk *elements* and return the minimal set of subtrees rooted at new IDs.
@@ -4751,7 +4708,10 @@ async def locate_dropdown_menu(
await skyvern_frame.scroll_to_x_y(x, y)
# TODO: better to send untrimmed HTML without skyvern attributes in the future
- dropdown_confirm_prompt = prompt_engine.load_prompt("opened-dropdown-confirm")
+ dropdown_confirm_prompt = prompt_engine.load_prompt(
+ "opened-dropdown-confirm",
+ non_vision_page_context=await build_non_vision_page_context_if_needed(page=skyvern_frame.get_frame()),
+ )
LOG.debug(
"Confirm if it's an opened dropdown menu",
element=element_dict,
@@ -5180,6 +5140,7 @@ async def extract_information_for_navigation_goal(
extracted_text=extracted_text_for_prompt,
error_code_mapping_str=error_code_mapping_str,
local_datetime=local_datetime_str,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(scraped_page=scraped_page_refreshed),
)
# Self-heal guard: on the second retry onward (``retry_index > 1``) the
@@ -5227,6 +5188,7 @@ async def extract_information_for_navigation_goal(
previous_extracted_information=post_ceiling_kwargs["previous_extracted_information"],
llm_key=llm_key_override,
workflow_system_prompt=task.workflow_system_prompt,
+ non_vision_page_context=post_ceiling_kwargs.get("non_vision_page_context"),
)
if is_retry_step:
# Proactively evict the in-run entry. The cross-run tier will be
@@ -5676,6 +5638,7 @@ async def extract_user_defined_errors(
error_code_mapping_str=json.dumps(task.error_code_mapping) if task.error_code_mapping else "{}",
local_datetime=datetime.now(skyvern_context.ensure_context().tz_info).isoformat(),
reasoning=reasoning,
+ non_vision_page_context=await build_non_vision_page_context_if_needed(scraped_page=scraped_page_refreshed),
)
json_response = await app.EXTRACTION_LLM_API_HANDLER(
prompt=prompt,
diff --git a/skyvern/webeye/scraper/non_vision_context.py b/skyvern/webeye/scraper/non_vision_context.py
new file mode 100644
index 000000000..0cb5c84b1
--- /dev/null
+++ b/skyvern/webeye/scraper/non_vision_context.py
@@ -0,0 +1,270 @@
+from __future__ import annotations
+
+import json
+import re
+from typing import Any
+
+import structlog
+from playwright.async_api import Frame, Page
+
+from skyvern.constants import SKYVERN_ID_ATTR
+from skyvern.forge.sdk.core import skyvern_context
+
+LOG = structlog.get_logger()
+
+MAX_NON_VISION_CONTEXT_CHARS = 20_000
+MAX_VISIBLE_TEXT_CHARS = 6_000
+MAX_ACCESSIBILITY_NODES = 160
+_SENSITIVE_VALUE_RE = re.compile(
+ r"(password|passcode|one[-_\s]?time[-_\s]?code|otp|token|secret|api[-_\s]?key|access[-_\s]?key|"
+ r"private[-_\s]?key|cvv|cvc|security[-_\s]?code|ssn|social[-_\s]?security|card[-_\s]?number|"
+ r"credit[-_\s]?card)",
+ re.IGNORECASE,
+)
+
+_ACCESSIBILITY_CONTEXT_SCRIPT = """
+({ skyvernIdAttr, maxNodes, maxVisibleTextChars }) => {
+ const normalize = (value) => (value || "").replace(/\\s+/g, " ").trim();
+ const truncate = (value, limit) => {
+ const text = normalize(value);
+ return text.length > limit ? text.slice(0, limit) + "..." : text;
+ };
+ const isVisible = (el) => {
+ const style = window.getComputedStyle(el);
+ if (!style || style.visibility === "hidden" || style.display === "none" || Number(style.opacity) === 0) {
+ return false;
+ }
+ const rect = el.getBoundingClientRect();
+ return rect.width > 0 && rect.height > 0 && rect.bottom >= 0 && rect.right >= 0
+ && rect.top <= window.innerHeight && rect.left <= window.innerWidth;
+ };
+ const textByIds = (ids) => normalize(ids.split(/\\s+/).map((id) => {
+ const ref = document.getElementById(id);
+ return ref ? (ref.innerText || ref.textContent || "") : "";
+ }).join(" "));
+ const labelText = (el) => {
+ const aria = el.getAttribute("aria-label");
+ if (aria) return aria;
+ const labelledBy = el.getAttribute("aria-labelledby");
+ if (labelledBy) {
+ const text = textByIds(labelledBy);
+ if (text) return text;
+ }
+ const id = el.getAttribute("id");
+ if (id) {
+ const escapedId = window.CSS && CSS.escape ? CSS.escape(id) : id.replace(/["\\\\]/g, "\\\\$&");
+ const label = document.querySelector(`label[for="${escapedId}"]`);
+ if (label) return label.innerText || label.textContent || "";
+ }
+ const parentLabel = el.closest("label");
+ if (parentLabel) return parentLabel.innerText || parentLabel.textContent || "";
+ return el.getAttribute("title") || el.getAttribute("alt") || el.getAttribute("placeholder") || "";
+ };
+ const implicitRole = (el) => {
+ const tag = el.tagName.toLowerCase();
+ const type = (el.getAttribute("type") || "").toLowerCase();
+ if (tag === "a" && el.getAttribute("href")) return "link";
+ if (tag === "button") return "button";
+ if (tag === "select") return "combobox";
+ if (tag === "textarea") return "textbox";
+ if (tag === "input") {
+ if (type === "checkbox") return "checkbox";
+ if (type === "radio") return "radio";
+ if (type === "submit" || type === "button") return "button";
+ return "textbox";
+ }
+ if (/^h[1-6]$/.test(tag)) return "heading";
+ if (tag === "img") return "img";
+ return "";
+ };
+ const rgb = (value) => {
+ const match = (value || "").match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);
+ if (!match) return null;
+ return { r: Number(match[1]), g: Number(match[2]), b: Number(match[3]) };
+ };
+ const isErrorColor = (value) => {
+ const color = rgb(value);
+ return color && color.r > 140 && color.r > color.g * 1.4 && color.r > color.b * 1.4;
+ };
+ const selector = [
+ "a[href]", "button", "input", "select", "textarea", "summary", "option",
+ "[role]", "[aria-label]", "[aria-labelledby]", "[aria-describedby]",
+ "[aria-invalid]", "[aria-expanded]", "[aria-selected]", "[aria-checked]",
+ "[tabindex]:not([tabindex='-1'])", "[data-testid]"
+ ].join(",");
+ const nodes = [];
+ for (const el of Array.from(document.querySelectorAll(selector))) {
+ if (nodes.length >= maxNodes) break;
+ if (!isVisible(el)) continue;
+ const style = window.getComputedStyle(el);
+ const rect = el.getBoundingClientRect();
+ const tag = el.tagName.toLowerCase();
+ const role = el.getAttribute("role") || implicitRole(el);
+ const text = truncate(el.innerText || el.textContent || "", 220);
+ const name = truncate(labelText(el), 220);
+ const node = {
+ skyvern_id: el.getAttribute(skyvernIdAttr) || null,
+ tag,
+ role: role || null,
+ name: name || null,
+ text: text && text !== name ? text : null,
+ type: el.getAttribute("type") || null,
+ value: tag === "input" || tag === "textarea" || tag === "select" ? truncate(el.value, 120) : null,
+ autocomplete: el.getAttribute("autocomplete") || null,
+ html_id: el.getAttribute("id") || null,
+ html_name: el.getAttribute("name") || null,
+ placeholder: el.getAttribute("placeholder") || null,
+ disabled: el.disabled === true || el.getAttribute("aria-disabled") === "true" || null,
+ required: el.required === true || el.getAttribute("aria-required") === "true" || null,
+ checked: el.checked === true || el.getAttribute("aria-checked") || null,
+ selected: el.selected === true || el.getAttribute("aria-selected") || null,
+ expanded: el.getAttribute("aria-expanded") || null,
+ invalid: el.getAttribute("aria-invalid") || (el.validity && !el.validity.valid) || null,
+ validation_message: el.validationMessage || null,
+ error_color: isErrorColor(style.color) ? style.color : null,
+ rect: {
+ x: Math.round(rect.x),
+ y: Math.round(rect.y),
+ width: Math.round(rect.width),
+ height: Math.round(rect.height)
+ }
+ };
+ for (const key of Object.keys(node)) {
+ if (node[key] === null) delete node[key];
+ }
+ if (node.name || node.text || node.role || node.skyvern_id || node.placeholder || node.value) {
+ nodes.push(node);
+ }
+ }
+ return {
+ title: document.title || "",
+ url: window.location.href,
+ viewport: { width: window.innerWidth, height: window.innerHeight },
+ visible_text: truncate(document.body ? document.body.innerText : "", maxVisibleTextChars),
+ accessibility_tree: nodes
+ };
+}
+"""
+
+
+def _truncate(text: str | None, max_chars: int) -> str | None:
+ if not text:
+ return None
+ normalized = " ".join(text.split())
+ if len(normalized) <= max_chars:
+ return normalized
+ return normalized[:max_chars] + "..."
+
+
+def _redact_sensitive_values(page_context: dict[str, Any]) -> bool:
+ nodes = page_context.get("accessibility_tree")
+ if not isinstance(nodes, list):
+ return False
+
+ redacted_sensitive_value = False
+ for node in nodes:
+ if not isinstance(node, dict) or "value" not in node:
+ continue
+ sensitive_fields = [
+ node.get("type"),
+ node.get("name"),
+ node.get("placeholder"),
+ node.get("autocomplete"),
+ node.get("html_id"),
+ node.get("html_name"),
+ ]
+ haystack = " ".join(str(value) for value in sensitive_fields if value)
+ if _SENSITIVE_VALUE_RE.search(haystack):
+ node.pop("value", None)
+ node["value_redacted"] = True
+ redacted_sensitive_value = True
+
+ return redacted_sensitive_value
+
+
+def _json_dumps(page_context: dict[str, Any]) -> str:
+ return json.dumps(page_context, separators=(",", ":"), default=str)
+
+
+def _bounded_json_context(page_context: dict[str, Any], max_chars: int) -> str:
+ rendered = _json_dumps(page_context)
+ if len(rendered) <= max_chars:
+ return rendered
+
+ bounded = dict(page_context)
+ bounded["truncated"] = True
+ if isinstance(bounded.get("visible_text"), str):
+ bounded["visible_text"] = _truncate(bounded["visible_text"], min(MAX_VISIBLE_TEXT_CHARS, max_chars // 4))
+
+ nodes = bounded.get("accessibility_tree")
+ if isinstance(nodes, list):
+ bounded["accessibility_tree"] = list(nodes)
+ while bounded["accessibility_tree"] and len(_json_dumps(bounded)) > max_chars:
+ keep_count = max(0, len(bounded["accessibility_tree"]) // 2)
+ bounded["accessibility_tree"] = bounded["accessibility_tree"][:keep_count]
+
+ rendered = _json_dumps(bounded)
+ if len(rendered) <= max_chars:
+ return rendered
+
+ fallback: dict[str, Any] = {"truncated": True}
+ for key in ("url", "title"):
+ value = bounded.get(key)
+ if value:
+ fallback[key] = _truncate(str(value), max_chars // 4)
+ rendered = _json_dumps(fallback)
+ return rendered if len(rendered) <= max_chars else _json_dumps({"truncated": True})
+
+
+async def _safe_page_context(page: Frame | Page | None) -> tuple[dict[str, Any], bool]:
+ if page is None:
+ return {}, False
+ try:
+ result = await page.evaluate(
+ _ACCESSIBILITY_CONTEXT_SCRIPT,
+ {
+ "skyvernIdAttr": SKYVERN_ID_ATTR,
+ "maxNodes": MAX_ACCESSIBILITY_NODES,
+ "maxVisibleTextChars": MAX_VISIBLE_TEXT_CHARS,
+ },
+ )
+ if not isinstance(result, dict):
+ return {}, False
+ redacted_sensitive_values = _redact_sensitive_values(result)
+ if redacted_sensitive_values:
+ result.pop("visible_text", None)
+ return result, redacted_sensitive_values
+ except Exception:
+ LOG.warning("Failed to build non-vision page context", exc_info=True)
+ return {}, False
+
+
+async def build_non_vision_page_context(
+ *,
+ scraped_page: Any | None = None,
+ page: Frame | Page | None = None,
+ max_chars: int = MAX_NON_VISION_CONTEXT_CHARS,
+) -> str | None:
+ page_context, redacted_sensitive_values = await _safe_page_context(page)
+ if scraped_page is not None:
+ page_context.setdefault("url", getattr(scraped_page, "url", None))
+ extracted_text = _truncate(getattr(scraped_page, "extracted_text", None), MAX_VISIBLE_TEXT_CHARS)
+ if extracted_text and not page_context.get("visible_text") and not redacted_sensitive_values:
+ page_context["visible_text"] = extracted_text
+
+ if not page_context:
+ return None
+
+ return _bounded_json_context(page_context, max_chars)
+
+
+async def build_non_vision_page_context_if_needed(
+ *,
+ scraped_page: Any | None = None,
+ page: Frame | Page | None = None,
+ max_chars: int = MAX_NON_VISION_CONTEXT_CHARS,
+) -> str | None:
+ context = skyvern_context.current()
+ if not context or not context.disable_llm_screenshots:
+ return None
+ return await build_non_vision_page_context(scraped_page=scraped_page, page=page, max_chars=max_chars)
diff --git a/tests/unit/test_copilot_enforcement_repeated_reply.py b/tests/unit/test_copilot_enforcement_repeated_reply.py
new file mode 100644
index 000000000..ea4994eaa
--- /dev/null
+++ b/tests/unit/test_copilot_enforcement_repeated_reply.py
@@ -0,0 +1,129 @@
+"""Coverage for the post-output ``apply_repeated_reply_guard`` and the
+AST-walked invariants the plan §4 requires: every ``AgentResult(...)``
+construction site populates ``turn_outcome``, and the v2 route forwards it
+when persisting assistant rows.
+"""
+
+from __future__ import annotations
+
+import ast
+from pathlib import Path
+
+from skyvern.forge.sdk.copilot.signature import compute_signature
+from skyvern.forge.sdk.copilot.turn_outcome import (
+ HANDOFF_REPLY,
+ IDENTICAL_REPLY_BLOCKED_TERMINAL_REASON,
+ apply_repeated_reply_guard,
+ escalation_reply_for,
+)
+from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind
+
+_AGENT_PY = Path(__file__).resolve().parents[2] / "skyvern" / "forge" / "sdk" / "copilot" / "agent.py"
+_ROUTE_PY = Path(__file__).resolve().parents[2] / "skyvern" / "forge" / "sdk" / "routes" / "workflow_copilot.py"
+
+
+def _call_name(node: ast.Call) -> str:
+ func = node.func
+ if isinstance(func, ast.Name):
+ return func.id
+ if isinstance(func, ast.Attribute):
+ return func.attr
+ return ""
+
+
+def _agent_result_calls(source_path: Path) -> list[ast.Call]:
+ tree = ast.parse(source_path.read_text(encoding="utf-8"))
+ return [n for n in ast.walk(tree) if isinstance(n, ast.Call) and _call_name(n) == "AgentResult"]
+
+
+def test_guard_returns_original_when_no_match() -> None:
+ text = "Drafted v1 of the workflow."
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=text,
+ attempted_kind=ResponseKind.BUILD,
+ blocked_signatures=["other"],
+ reason_code="ok",
+ )
+ assert final_text == text
+ assert outcome.response_kind is ResponseKind.BUILD
+ assert outcome.normalized_reply_signature == compute_signature(text)
+ assert outcome.blocked_signatures == ["other"]
+ assert outcome.reason_code == "ok"
+
+
+def test_guard_rewrites_to_escalation_when_signature_matches() -> None:
+ text = "The file is in the Artifacts section."
+ sig = compute_signature(text)
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=text,
+ attempted_kind=ResponseKind.DIAGNOSE,
+ blocked_signatures=[sig],
+ )
+ assert final_text == escalation_reply_for(ResponseKind.DIAGNOSE)
+ assert outcome.response_kind is ResponseKind.RECOVER
+ assert outcome.terminal_reason == IDENTICAL_REPLY_BLOCKED_TERMINAL_REASON
+ assert sig in outcome.blocked_signatures
+ assert outcome.normalized_reply_signature == compute_signature(final_text)
+
+
+def test_guard_falls_back_to_handoff_on_escalation_self_collision() -> None:
+ text = "The file is in the Artifacts section."
+ original_sig = compute_signature(text)
+ escalation_sig = compute_signature(escalation_reply_for(ResponseKind.DIAGNOSE))
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text=text,
+ attempted_kind=ResponseKind.DIAGNOSE,
+ blocked_signatures=[original_sig, escalation_sig],
+ )
+ assert final_text == HANDOFF_REPLY
+ assert outcome.response_kind is ResponseKind.RECOVER
+ assert original_sig in outcome.blocked_signatures
+ assert escalation_sig in outcome.blocked_signatures
+
+
+def test_guard_carries_inherited_bans_forward_on_no_match() -> None:
+ final_text, outcome = apply_repeated_reply_guard(
+ final_text="completely new reply",
+ attempted_kind=ResponseKind.BUILD,
+ blocked_signatures=["banned_a", "banned_b"],
+ )
+ assert outcome.blocked_signatures == ["banned_a", "banned_b"]
+
+
+def test_every_agent_result_construction_site_populates_turn_outcome() -> None:
+ calls = _agent_result_calls(_AGENT_PY)
+ assert calls, "expected at least one AgentResult(...) call in agent.py"
+ failures: list[int] = [call.lineno for call in calls if not any(kw.arg == "turn_outcome" for kw in call.keywords)]
+ assert not failures, f"AgentResult(...) sites missing turn_outcome=: lines {failures}"
+
+
+def test_inherited_blocked_signatures_are_threaded_through_agent_paths() -> None:
+ tree = ast.parse(_AGENT_PY.read_text(encoding="utf-8"))
+ threaded = 0
+ for node in ast.walk(tree):
+ if not isinstance(node, ast.Call):
+ continue
+ for kw in node.keywords:
+ if kw.arg in ("blocked_signatures", "inherited_blocked_signatures") and (
+ "ctx.blocked_reply_signatures" in ast.unparse(kw.value)
+ ):
+ threaded += 1
+ assert threaded >= 5, (
+ "expected ctx.blocked_reply_signatures to be threaded into apply_repeated_reply_guard / "
+ f"build_minimal_turn_outcome at multiple sites; saw {threaded}"
+ )
+
+
+def test_route_persists_turn_outcome_on_v2_assistant_rows() -> None:
+ tree = ast.parse(_ROUTE_PY.read_text(encoding="utf-8"))
+ forwarded = 0
+ for node in ast.walk(tree):
+ if not isinstance(node, ast.Call):
+ continue
+ for kw in node.keywords:
+ if kw.arg != "turn_outcome":
+ continue
+ expr = ast.unparse(kw.value)
+ if expr in ("agent_result.turn_outcome", "turn_outcome") or expr.startswith("getattr(agent_result"):
+ forwarded += 1
+ assert forwarded >= 2, f"expected the v2 route to forward turn_outcome on assistant rows; saw {forwarded}"
diff --git a/tests/unit/test_copilot_repeated_reply_summary.py b/tests/unit/test_copilot_repeated_reply_summary.py
new file mode 100644
index 000000000..4e0b17a7e
--- /dev/null
+++ b/tests/unit/test_copilot_repeated_reply_summary.py
@@ -0,0 +1,158 @@
+from __future__ import annotations
+
+from datetime import datetime, timezone
+
+from skyvern.forge.sdk.copilot.repeated_reply_summary import (
+ RepeatedReplyKind,
+ summarize_repeated_replies,
+)
+from skyvern.forge.sdk.copilot.signature import compute_signature
+from skyvern.forge.sdk.copilot.turn_intent import TurnIntent, TurnIntentReasonCode
+from skyvern.forge.sdk.copilot.turn_outcome import build_minimal_turn_outcome
+from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind, TurnOutcome
+from skyvern.forge.sdk.schemas.workflow_copilot import (
+ WorkflowCopilotChatHistoryMessage,
+ WorkflowCopilotChatSender,
+)
+
+
+def _user(content: str) -> WorkflowCopilotChatHistoryMessage:
+ return WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.USER,
+ content=content,
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ )
+
+
+def _ai(content: str, outcome: TurnOutcome | None) -> WorkflowCopilotChatHistoryMessage:
+ return WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.AI,
+ content=content,
+ turn_outcome=outcome,
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ )
+
+
+def _outcome(
+ content: str,
+ *,
+ response_kind: ResponseKind = ResponseKind.DIAGNOSE,
+ blocked: list[str] | None = None,
+) -> TurnOutcome:
+ return build_minimal_turn_outcome(
+ content,
+ response_kind=response_kind,
+ inherited_blocked_signatures=blocked or [],
+ )
+
+
+def _intent(*, stuck: bool) -> TurnIntent:
+ reason_codes = [TurnIntentReasonCode.REQUEST_POLICY_DERIVED]
+ if stuck:
+ reason_codes.append(TurnIntentReasonCode.USER_NON_PROGRESS)
+ return TurnIntent(reason_codes=reason_codes)
+
+
+_ANSWER = "The file is stored in the Artifacts section of the run results page."
+
+
+def test_empty_history_is_no_repeat() -> None:
+ assert summarize_repeated_replies([], _intent(stuck=True)).kind is RepeatedReplyKind.NO_REPEAT
+
+
+def test_no_user_non_progress_signal_does_not_trip() -> None:
+ outcome = _outcome(_ANSWER)
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, outcome),
+ _user("i cannot see it"),
+ _ai(_ANSWER, outcome),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=False))
+ assert summary.kind is RepeatedReplyKind.NO_REPEAT
+
+
+def test_fresh_trip_fires_when_signatures_match_and_intent_marks_non_progress() -> None:
+ outcome = _outcome(_ANSWER)
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, outcome),
+ _user("i cannot see it"),
+ _ai(_ANSWER, outcome),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert summary.kind is RepeatedReplyKind.REPEATED_REPLY_DETECTED
+ assert outcome.normalized_reply_signature in summary.blocked_signatures
+
+
+def test_distinct_replies_do_not_fire_even_with_non_progress_signal() -> None:
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, _outcome(_ANSWER)),
+ _user("i still cannot see it"),
+ _ai("I have emailed it to your account.", _outcome("I have emailed it.")),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert summary.kind is RepeatedReplyKind.NO_REPEAT
+
+
+def test_inherited_ban_survives_a_timeout_interruption() -> None:
+ inherited = compute_signature(_ANSWER)
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, _outcome(_ANSWER, blocked=[inherited])),
+ _user("i still cannot see it"),
+ _ai("I ran out of time. Here's what I have so far.", None),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert summary.kind is RepeatedReplyKind.REPEATED_REPLY_DETECTED
+ assert inherited in summary.blocked_signatures
+
+
+def test_signature_only_in_one_outcome_does_not_create_fresh_trip() -> None:
+ history = [
+ _user("hi"),
+ _ai(_ANSWER, _outcome(_ANSWER)),
+ _user("i cannot see it"),
+ _ai("Different reply.", _outcome("Different reply.")),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert summary.kind is RepeatedReplyKind.NO_REPEAT
+
+
+def test_inherited_ban_clears_when_intent_drops_the_signal() -> None:
+ inherited = compute_signature(_ANSWER)
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, _outcome(_ANSWER, blocked=[inherited])),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=False))
+ assert summary.kind is RepeatedReplyKind.NO_REPEAT
+
+
+def test_blocked_signatures_dedup_across_outcomes() -> None:
+ inherited = compute_signature(_ANSWER)
+ history = [
+ _user("hi"),
+ _ai(_ANSWER, _outcome(_ANSWER, blocked=[inherited, inherited])),
+ _user("i cannot see it"),
+ _ai(_ANSWER, _outcome(_ANSWER, blocked=[inherited])),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert summary.kind is RepeatedReplyKind.REPEATED_REPLY_DETECTED
+ assert summary.blocked_signatures.count(inherited) == 1
+
+
+def test_render_prompt_block_only_populated_when_detected() -> None:
+ outcome = _outcome(_ANSWER)
+ history = [
+ _user("where is my file"),
+ _ai(_ANSWER, outcome),
+ _user("i cannot see it"),
+ _ai(_ANSWER, outcome),
+ ]
+ summary = summarize_repeated_replies(history, _intent(stuck=True))
+ assert "repeated_reply_detected" in summary.render_prompt_block()
+
+ empty = summarize_repeated_replies([], _intent(stuck=True))
+ assert empty.render_prompt_block() == ""
diff --git a/tests/unit/test_copilot_turn_context.py b/tests/unit/test_copilot_turn_context.py
index a58ee1ca4..2c0b47661 100644
--- a/tests/unit/test_copilot_turn_context.py
+++ b/tests/unit/test_copilot_turn_context.py
@@ -58,6 +58,72 @@ def test_edit_turn_includes_workflow_proposal_and_transcript_context() -> None:
assert packet.omissions == []
+def test_repeated_reply_context_attached_when_assistant_repeats() -> None:
+ from skyvern.forge.sdk.copilot.turn_intent import TurnIntentReasonCode
+ from skyvern.forge.sdk.copilot.turn_outcome import build_minimal_turn_outcome
+ from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind
+
+ answer = "The file is stored as an artifact in the Artifacts section of the run results page."
+ outcome = build_minimal_turn_outcome(answer, response_kind=ResponseKind.DIAGNOSE)
+ history = [
+ WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.USER,
+ content="where is my file",
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ ),
+ WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.AI,
+ content=answer,
+ turn_outcome=outcome,
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ ),
+ WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.USER,
+ content="i cannot see it",
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ ),
+ WorkflowCopilotChatHistoryMessage(
+ sender=WorkflowCopilotChatSender.AI,
+ content=answer,
+ turn_outcome=outcome,
+ created_at=datetime(2026, 1, 1, tzinfo=timezone.utc),
+ ),
+ ]
+ packet = TurnContextAssembler().assemble(
+ TurnContextInputs(
+ turn_intent=TurnIntent(
+ mode=TurnIntentMode.UNKNOWN,
+ reason_codes=[TurnIntentReasonCode.USER_NON_PROGRESS],
+ ),
+ request_policy=RequestPolicy(),
+ user_message="i still cannot see it",
+ chat_history=history,
+ )
+ )
+
+ assert packet.repeated_reply_context is not None
+ assert outcome.normalized_reply_signature in packet.repeated_reply_context.blocked_signatures
+ assert "repeated_reply_detected" in packet.repeated_reply_context.rendered_summary
+ trace = packet.to_trace_data()
+ assert "repeated_reply_context" in trace["sections"]
+
+
+def test_repeated_reply_context_omitted_without_repeat() -> None:
+ packet = TurnContextAssembler().assemble(
+ TurnContextInputs(
+ turn_intent=TurnIntent(mode=TurnIntentMode.UNKNOWN),
+ request_policy=RequestPolicy(),
+ user_message="where is my file",
+ chat_history=_history(("user", "build a workflow"), ("ai", "Drafted v1")),
+ )
+ )
+
+ assert packet.repeated_reply_context is None
+ trace = packet.to_trace_data()
+ assert "repeated_reply_context" not in trace["sections"]
+ assert trace["repeated_reply_count"] == 0
+
+
def test_diagnose_turn_includes_run_context_or_reports_missing() -> None:
available = TurnContextAssembler().assemble(
TurnContextInputs(
diff --git a/tests/unit/test_copilot_turn_outcome.py b/tests/unit/test_copilot_turn_outcome.py
index 132f53809..3f841698a 100644
--- a/tests/unit/test_copilot_turn_outcome.py
+++ b/tests/unit/test_copilot_turn_outcome.py
@@ -8,6 +8,7 @@ from skyvern.forge.sdk.copilot.turn_outcome import (
build_minimal_turn_outcome,
build_turn_outcome,
derive_response_kind,
+ escalation_reply_for,
)
from skyvern.forge.sdk.schemas.copilot_turn_outcome import ResponseKind, TurnOutcome
@@ -72,3 +73,14 @@ def test_turn_outcome_json_round_trip() -> None:
payload = outcome.model_dump(mode="json")
restored = TurnOutcome.model_validate(payload)
assert restored == outcome
+
+
+def test_escalation_reply_for_covers_derivable_kinds() -> None:
+ for kind in (ResponseKind.BUILD, ResponseKind.CLARIFY, ResponseKind.DIAGNOSE, ResponseKind.REFUSE):
+ text = escalation_reply_for(kind)
+ assert isinstance(text, str)
+ assert text
+
+
+def test_escalation_reply_for_recover_falls_back_to_clarify_text() -> None:
+ assert escalation_reply_for(ResponseKind.RECOVER) == escalation_reply_for(ResponseKind.CLARIFY)
diff --git a/tests/unit/test_date_dropdown_emerging_selection.py b/tests/unit/test_date_dropdown_emerging_selection.py
deleted file mode 100644
index daaade388..000000000
--- a/tests/unit/test_date_dropdown_emerging_selection.py
+++ /dev/null
@@ -1,109 +0,0 @@
-from pathlib import Path
-from typing import Any
-
-import pytest
-from jinja2 import Template
-
-from skyvern.webeye.actions import handler
-from skyvern.webeye.actions.handler import CustomSelectPromptOptions
-from skyvern.webeye.actions.responses import ActionFailure, ActionSuccess
-
-
-async def test_date_dropdown_tries_emerging_element_selection(monkeypatch: pytest.MonkeyPatch) -> None:
- captured: dict[str, Any] = {}
-
- async def fake_select_from_emerging_elements(**kwargs: Any) -> ActionSuccess:
- captured.update(kwargs)
- return ActionSuccess(data={"selected": "01.01.2026"})
-
- monkeypatch.setattr(handler, "select_from_emerging_elements", fake_select_from_emerging_elements)
- options = CustomSelectPromptOptions(
- field_information="From date",
- is_date_related=True,
- required_field=True,
- )
-
- result = await handler._select_date_from_emerging_elements_or_skip(
- current_element_id="date-anchor",
- options=options,
- page=object(),
- scraped_page=object(),
- step=object(),
- task=object(),
- scraped_page_after_open=object(),
- new_interactable_element_ids=["day-1"],
- )
-
- assert result.success is True
- assert result.skip_remaining_actions is True
- assert captured["current_element_id"] == "date-anchor"
- assert captured["options"] is options
- assert captured["new_interactable_element_ids"] == ["day-1"]
-
-
-async def test_date_dropdown_preserves_skip_behavior_when_selection_fails(monkeypatch: pytest.MonkeyPatch) -> None:
- async def fake_select_from_emerging_elements(**kwargs: Any) -> ActionSuccess:
- raise RuntimeError("no exact date option")
-
- monkeypatch.setattr(handler, "select_from_emerging_elements", fake_select_from_emerging_elements)
-
- result = await handler._select_date_from_emerging_elements_or_skip(
- current_element_id="date-anchor",
- options=CustomSelectPromptOptions(field_information="From date", is_date_related=True),
- page=object(),
- scraped_page=object(),
- step=object(),
- task=object(),
- scraped_page_after_open=object(),
- new_interactable_element_ids=["day-1"],
- )
-
- assert result.success is True
- assert result.skip_remaining_actions is True
-
-
-async def test_date_dropdown_preserves_skip_behavior_when_selection_returns_failure(
- monkeypatch: pytest.MonkeyPatch,
-) -> None:
- async def fake_select_from_emerging_elements(**kwargs: Any) -> ActionFailure:
- return ActionFailure(exception=RuntimeError("date option was not actionable"))
-
- monkeypatch.setattr(handler, "select_from_emerging_elements", fake_select_from_emerging_elements)
-
- result = await handler._select_date_from_emerging_elements_or_skip(
- current_element_id="date-anchor",
- options=CustomSelectPromptOptions(field_information="From date", is_date_related=True),
- page=object(),
- scraped_page=object(),
- step=object(),
- task=object(),
- scraped_page_after_open=object(),
- new_interactable_element_ids=["day-1"],
- )
-
- assert result.success is True
- assert result.skip_remaining_actions is True
-
-
-def test_custom_select_date_guidance_renders_without_select_history() -> None:
- template_path = Path("skyvern/forge/prompts/skyvern/custom-select.j2")
- prompt = Template(template_path.read_text()).render(
- field_information="From date",
- required_field=True,
- is_date_related=True,
- navigation_goal="Set the from date to 01.01.2026.",
- navigation_payload_str="{}",
- elements='<button id="day-1">01</button><button>Today</button>',
- new_elements_ids=["day-1"],
- select_history="",
- target_value="01.01.2026",
- support_complete_action=False,
- local_datetime="2026-05-21T12:00:00",
- )
-
- assert "A date picker might be triggered." in prompt
- assert 'Do not choose "Today" unless the target date is today.' in prompt
- assert "Select History:" not in prompt
diff --git a/tests/unit/test_default_task_version.py b/tests/unit/test_default_task_version.py
index edbdb6747..04c4bff83 100644
--- a/tests/unit/test_default_task_version.py
+++ b/tests/unit/test_default_task_version.py
@@ -90,13 +90,23 @@ class TestTaskRunRequestEngine:
req = TaskRunRequest(prompt="hello", engine=RunEngine.skyvern_v2)
assert req.engine == RunEngine.skyvern_v2
- def test_publish_workflow_forces_v2(self) -> None:
- """publish_workflow=True must force engine to v2, since v1 doesn't support it."""
+ def test_publish_workflow_routes_to_legacy_v2(self) -> None:
+ """publish_workflow=True keeps existing callers on the legacy v2 publish path."""
from skyvern.schemas.runs import RunEngine, TaskRunRequest
req = TaskRunRequest(prompt="hello", publish_workflow=True)
assert req.engine == RunEngine.skyvern_v2
+ req = TaskRunRequest(prompt="hello", engine=RunEngine.skyvern_v1, publish_workflow=True)
+ assert req.engine == RunEngine.skyvern_v2
+
+ def test_publish_workflow_with_explicit_v2_preserved(self) -> None:
+ """Explicit v2 publish_workflow requests stay on the v2 path."""
+ from skyvern.schemas.runs import RunEngine, TaskRunRequest
+
+ req = TaskRunRequest(prompt="hello", engine=RunEngine.skyvern_v2, publish_workflow=True)
+ assert req.engine == RunEngine.skyvern_v2
+
def test_publish_workflow_false_keeps_v1(self) -> None:
"""publish_workflow=False (default) should keep the v1 default."""
from skyvern.schemas.runs import RunEngine, TaskRunRequest
diff --git a/tests/unit/test_disable_llm_screenshots_flag.py b/tests/unit/test_disable_llm_screenshots_flag.py
index 887d59f07..09a61b3bd 100644
--- a/tests/unit/test_disable_llm_screenshots_flag.py
+++ b/tests/unit/test_disable_llm_screenshots_flag.py
@@ -24,6 +24,14 @@ def test_screenshots_stripped_when_flag_on() -> None:
assert _llm_screenshots_enabled_metric(config, ctx) is False
+def test_vision_fallback_prompt_keeps_screenshots_when_flag_on() -> None:
+ config = MagicMock(spec=LLMConfig)
+ config.supports_vision = True
+ ctx = SkyvernContext(disable_llm_screenshots=True)
+ assert _llm_screenshots_for_call([b"png"], config, ctx, "extract-text-from-image") == [b"png"]
+ assert _llm_screenshots_enabled_metric(config, ctx, "extract-text-from-image") is True
+
+
def test_non_vision_model_never_attaches() -> None:
config = MagicMock(spec=LLMConfig)
config.supports_vision = False
diff --git a/tests/unit/test_init_command.py b/tests/unit/test_init_command.py
index 4fad7634b..a6aac409e 100644
--- a/tests/unit/test_init_command.py
+++ b/tests/unit/test_init_command.py
@@ -1,7 +1,9 @@
from __future__ import annotations
import subprocess
+from collections.abc import Callable
from pathlib import Path
+from typing import Any
import pytest
@@ -46,4 +48,58 @@ def test_run_with_server_dependency_install_installs_and_retries(monkeypatch: py
assert init_command._run_with_server_dependency_install(action) == "ok"
assert calls == ["action", "action"]
- assert install_calls == [["/usr/bin/python", "-m", "pip", "install", "skyvern[server]==1.2.3"]]
+ assert install_calls == [
+ [
+ "/usr/bin/python",
+ "-m",
+ "pip",
+ "install",
+ "--retries",
+ "5",
+ "--timeout",
+ "60",
+ "skyvern[server]==1.2.3",
+ ]
+ ]
+
+
+def test_init_env_wraps_local_org_setup_with_server_dependency_install(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ wrapped_results: list[Any] = []
+
+ def fake_run_with_server_dependency_install(action: Callable[[], Any]) -> Any:
+ result = action()
+ wrapped_results.append(result)
+ return result
+
+ async def fake_setup_local_organization() -> str:
+ return "skyvern-api-key"
+
+ env_updates: dict[str, str] = {}
+
+ def fake_update_or_add_env_var(key: str, value: str, **_kwargs: Any) -> None:
+ env_updates[key] = value
+
+ monkeypatch.setenv(init_command.BACKEND_ENV_FILE_ENV_VAR, "")
+ monkeypatch.setattr(init_command, "setup_postgresql", lambda *args, **kwargs: None)
+ monkeypatch.setattr("skyvern.utils.migrate_db", lambda: None)
+ monkeypatch.setattr(init_command, "_setup_local_organization_from_database", fake_setup_local_organization)
+ monkeypatch.setattr(init_command, "_run_with_server_dependency_install", fake_run_with_server_dependency_install)
+ monkeypatch.setattr(init_command, "update_or_add_env_var", fake_update_or_add_env_var)
+
+ result = init_command.init_env(
+ no_postgres=True,
+ skip_browser_install=True,
+ mode="local",
+ skip_llm_setup=True,
+ configure_mcp=False,
+ browser_type="cdp-connect",
+ analytics_id="anonymous",
+ env_path=tmp_path / ".env",
+ return_result=True,
+ )
+
+ assert result.run_local is True
+ assert wrapped_results == [None, "skyvern-api-key"]
+ assert env_updates["SKYVERN_API_KEY"] == "skyvern-api-key"
diff --git a/tests/unit/test_init_mcp.py b/tests/unit/test_init_mcp.py
index 056152d11..0054db577 100644
--- a/tests/unit/test_init_mcp.py
+++ b/tests/unit/test_init_mcp.py
@@ -40,7 +40,7 @@ def test_init_callback_passes_plain_database_string(monkeypatch) -> None:
monkeypatch.setattr(
"skyvern.cli.init_command.init_env",
- lambda no_postgres=False, database_string="", env_scope=None: calls.append(
+ lambda no_postgres=False, database_string="", env_scope=None, **kwargs: calls.append(
(no_postgres, database_string, env_scope)
),
)
diff --git a/tests/unit/test_load_prompt_with_elements_ceiling.py b/tests/unit/test_load_prompt_with_elements_ceiling.py
index 20c9abcde..f0ae68c16 100644
--- a/tests/unit/test_load_prompt_with_elements_ceiling.py
+++ b/tests/unit/test_load_prompt_with_elements_ceiling.py
@@ -19,13 +19,16 @@ def test_ceiling_fallback_keys_by_template_has_known_mappings() -> None:
"previous_extracted_information",
"extracted_information_schema",
"extracted_text",
+ "non_vision_page_context",
]
assert CEILING_FALLBACK_KEYS_BY_TEMPLATE["extract-action"] == [
"action_history",
"navigation_payload_str",
+ "non_vision_page_context",
]
assert CEILING_FALLBACK_KEYS_BY_TEMPLATE["data-extraction-summary"] == [
"data_extraction_schema",
+ "non_vision_page_context",
]
@@ -109,6 +112,33 @@ def test_load_prompt_with_elements_respects_ceiling_for_small_prompts() -> None:
assert count_tokens(rendered) <= PROMPT_HARD_CEILING_TOKENS
+def test_load_prompt_with_elements_tracked_drops_non_vision_context_as_last_resort() -> None:
+ from skyvern.forge.prompts import prompt_engine as engine_module
+ from skyvern.utils.prompt_engine import PROMPT_HARD_CEILING_TOKENS, load_prompt_with_elements_tracked
+ from skyvern.utils.token_counter import count_tokens
+
+ oversized_non_vision_context = '{"visible_text":"' + ("UNIQUE_NON_VISION_CONTEXT " * 300_000) + '"}'
+
+ rendered, post_kwargs = load_prompt_with_elements_tracked(
+ element_tree_builder=_make_element_tree_builder(),
+ prompt_engine=engine_module,
+ template_name="extract-information",
+ data_extraction_goal="Extract documents",
+ extracted_information_schema=None,
+ current_url="https://example.test",
+ extracted_text=None,
+ error_code_mapping_str=None,
+ navigation_payload=None,
+ local_datetime="2026-04-14T12:00:00",
+ previous_extracted_information=None,
+ non_vision_page_context=oversized_non_vision_context,
+ )
+
+ assert count_tokens(rendered) <= PROMPT_HARD_CEILING_TOKENS
+ assert "UNIQUE_NON_VISION_CONTEXT" not in rendered
+ assert post_kwargs["non_vision_page_context"] is None
+
+
def test_enforce_prompt_ceiling_tracked_reports_dropped_keys() -> None:
from skyvern.forge.prompts import prompt_engine as engine_module
from skyvern.utils.prompt_engine import PROMPT_HARD_CEILING_TOKENS, enforce_prompt_ceiling_tracked
diff --git a/tests/unit/test_non_vision_context.py b/tests/unit/test_non_vision_context.py
new file mode 100644
index 000000000..6c5c2707f
--- /dev/null
+++ b/tests/unit/test_non_vision_context.py
@@ -0,0 +1,162 @@
+from __future__ import annotations
+
+import json
+from types import SimpleNamespace
+
+import pytest
+
+from skyvern.forge.sdk.core.skyvern_context import SkyvernContext
+from skyvern.forge.sdk.prompting import NON_VISION_CONTEXT_HEADER, _with_non_vision_context
+from skyvern.webeye.scraper import non_vision_context
+
+
+def test_accessibility_context_script_keeps_backslash_regex_escaped() -> None:
+ assert '/["\\\\]/g' in non_vision_context._ACCESSIBILITY_CONTEXT_SCRIPT
+ assert '/["\\]/g' not in non_vision_context._ACCESSIBILITY_CONTEXT_SCRIPT
+
+
+class FakePage:
+ async def evaluate(self, _script: str, args: dict) -> dict:
+ return {
+ "title": "Example",
+ "url": "https://example.test",
+ "visible_text": "Save changes",
+ "accessibility_tree": [
+ {
+ "skyvern_id": "abc",
+ "tag": "button",
+ "role": "button",
+ "name": "Save",
+ }
+ ],
+ "max_nodes": args["maxNodes"],
+ }
+
+
+class SensitiveFakePage:
+ async def evaluate(self, _script: str, _args: dict) -> dict:
+ return {
+ "visible_text": "Password hunter2 One-time code 123456 Email [email protected]",
+ "accessibility_tree": [
+ {
+ "tag": "input",
+ "role": "textbox",
+ "name": "Password",
+ "type": "password",
+ "value": "hunter2",
+ },
+ {
+ "tag": "input",
+ "role": "textbox",
+ "name": "One-time code",
+ "type": "text",
+ "autocomplete": "one-time-code",
+ "value": "123456",
+ },
+ {
+ "tag": "input",
+ "role": "textbox",
+ "name": "Email",
+ "type": "email",
+ "value": "[email protected]",
+ },
+ ],
+ }
+
+
+class LargeFakePage:
+ async def evaluate(self, _script: str, _args: dict) -> dict:
+ return {
+ "title": "Large page",
+ "url": "https://example.test/large",
+ "visible_text": "Visible text " * 100,
+ "accessibility_tree": [
+ {
+ "tag": "button",
+ "role": "button",
+ "name": f"Button {index}",
+ "text": "Button text " * 20,
+ }
+ for index in range(20)
+ ],
+ }
+
+
+async def test_build_non_vision_context_if_needed_respects_disable_flag(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(non_vision_context.skyvern_context, "current", lambda: SkyvernContext())
+
+ rendered = await non_vision_context.build_non_vision_page_context_if_needed(page=FakePage())
+
+ assert rendered is None
+
+
+async def test_build_non_vision_context_includes_accessibility_tree(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(
+ non_vision_context.skyvern_context,
+ "current",
+ lambda: SkyvernContext(disable_llm_screenshots=True),
+ )
+ scraped_page = SimpleNamespace(url="https://fallback.test", extracted_text="Fallback text")
+
+ rendered = await non_vision_context.build_non_vision_page_context_if_needed(
+ scraped_page=scraped_page,
+ page=FakePage(),
+ )
+
+ assert rendered is not None
+ assert '"accessibility_tree"' in rendered
+ assert '"skyvern_id":"abc"' in rendered
+ assert '"visible_text":"Save changes"' in rendered
+
+
+async def test_build_non_vision_context_redacts_sensitive_input_values() -> None:
+ scraped_page = SimpleNamespace(
+ url="https://example.test/login",
+ extracted_text="Fallback text with password hunter2 and one-time code 123456",
+ )
+
+ rendered = await non_vision_context.build_non_vision_page_context(
+ page=SensitiveFakePage(), scraped_page=scraped_page
+ )
+
+ assert rendered is not None
+ assert "hunter2" not in rendered
+ assert "123456" not in rendered
+ assert rendered.count('"value_redacted":true') == 2
+ assert "[email protected]" in rendered
+ assert "visible_text" not in json.loads(rendered)
+
+
+async def test_build_non_vision_context_truncates_as_valid_json() -> None:
+ rendered = await non_vision_context.build_non_vision_page_context(page=LargeFakePage(), max_chars=250)
+
+ assert rendered is not None
+ assert len(rendered) <= 250
+ parsed = json.loads(rendered)
+ assert parsed["truncated"] is True
+
+
+def test_prompt_engine_appends_non_vision_context_once() -> None:
+ rendered = _with_non_vision_context(
+ "Base prompt",
+ "skyvern/example",
+ {"non_vision_page_context": '{"accessibility_tree":[]}'},
+ )
+
+ assert rendered.count(NON_VISION_CONTEXT_HEADER) == 1
+ assert '{"accessibility_tree":[]}' in rendered
+ assert _with_non_vision_context(rendered, "skyvern/example", {"non_vision_page_context": "{}"}) == rendered
+
+
+def test_prompt_engine_does_not_append_non_vision_context_to_static_cache_template() -> None:
+ rendered = _with_non_vision_context(
+ "Static prompt",
+ "skyvern/extract-action-static",
+ {"non_vision_page_context": '{"accessibility_tree":[]}'},
+ )
+
+ assert rendered == "Static prompt"
diff --git a/tests/unit/test_quickstart_command.py b/tests/unit/test_quickstart_command.py
index 3c019787e..3d5a87b66 100644
--- a/tests/unit/test_quickstart_command.py
+++ b/tests/unit/test_quickstart_command.py
@@ -479,7 +479,7 @@ def test_quickstart_server_flags_select_server_path_without_server_extra(monkeyp
monkeypatch.setattr(
quickstart_module,
"_install_server_extra_for_quickstart",
- lambda: install_calls.append("install") or True,
+ lambda **kwargs: install_calls.append(kwargs) or True,
)
monkeypatch.setattr(quickstart_module, "_run_server_quickstart", lambda **kwargs: server_calls.append(kwargs))
@@ -518,6 +518,15 @@ def test_quickstart_server_extra_probe_rejects_local_with_incidental_uvicorn(mon
assert quickstart_module._has_server_quickstart_extra() is False
+def test_quickstart_local_extra_probe_allows_missing_psycopg(monkeypatch) -> None:
+ monkeypatch.setattr(
+ "skyvern.exceptions.find_spec",
+ lambda module_name: None if module_name == "psycopg" else object(),
+ )
+
+ assert quickstart_module._has_local_quickstart_extra() is True
+
+
def test_quickstart_interactive_server_choice_without_server_extra_prints_install_steps(monkeypatch) -> None:
monkeypatch.setattr(quickstart_module, "check_docker_compose_file", lambda: False)
monkeypatch.setattr(quickstart_module, "_has_local_quickstart_extra", lambda: False)
@@ -547,14 +556,14 @@ def test_quickstart_interactive_server_choice_can_install_server_extra(monkeypat
monkeypatch.setattr(
quickstart_module,
"_install_server_extra_for_quickstart",
- lambda: install_calls.append("install") or True,
+ lambda **kwargs: install_calls.append(kwargs) or True,
)
monkeypatch.setattr(quickstart_module, "_run_server_quickstart", lambda **kwargs: server_calls.append(kwargs))
result = CliRunner().invoke(quickstart_module.quickstart_app, [], input="3\n")
assert result.exit_code == 0
- assert install_calls == ["install"]
+ assert install_calls == [{"assume_yes": False}]
assert server_calls == [
{
"no_postgres": False,
diff --git a/tests/unit/test_quickstart_server_extra.py b/tests/unit/test_quickstart_server_extra.py
new file mode 100644
index 000000000..a23b87dde
--- /dev/null
+++ b/tests/unit/test_quickstart_server_extra.py
@@ -0,0 +1,103 @@
+from __future__ import annotations
+
+import subprocess
+
+from typer.testing import CliRunner
+
+from skyvern.cli import quickstart as quickstart_module
+from skyvern.cli.quickstart import quickstart_app
+
+
+def test_install_server_extra_assume_yes_skips_prompt(monkeypatch) -> None:
+ commands: list[list[str]] = []
+
+ monkeypatch.setattr(quickstart_module, "_server_extra_install_target", lambda: "skyvern[server]==1.2.3")
+ monkeypatch.setattr(
+ quickstart_module.Confirm,
+ "ask",
+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),
+ )
+ monkeypatch.setattr(
+ quickstart_module.subprocess,
+ "run",
+ lambda command, **kwargs: commands.append(command) or subprocess.CompletedProcess(command, returncode=0),
+ )
+
+ assert quickstart_module._install_server_extra_for_quickstart(assume_yes=True) is True
+ assert commands == [
+ [
+ quickstart_module.sys.executable,
+ "-m",
+ "pip",
+ "install",
+ "--retries",
+ "5",
+ "--timeout",
+ "60",
+ "skyvern[server]==1.2.3",
+ ]
+ ]
+
+
+def test_quickstart_non_interactive_server_options_skip_prompts(monkeypatch) -> None:
+ calls: list[dict] = []
+
+ def fake_init_env(**kwargs):
+ calls.append(kwargs)
+ return False
+
+ monkeypatch.setattr("skyvern.cli.quickstart._has_server_quickstart_extra", lambda: True)
+ monkeypatch.setattr("skyvern.cli.quickstart.check_docker_compose_file", lambda: False)
+ monkeypatch.setattr("skyvern.cli.init_command.init_env", fake_init_env)
+ monkeypatch.setattr(
+ "skyvern.cli.quickstart.Confirm.ask",
+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),
+ )
+
+ result = CliRunner().invoke(
+ quickstart_app,
+ [
+ "--non-interactive",
+ "--skip-browser-install",
+ "--database-string",
+ "postgresql+psycopg://skyvern:skyvern@postgres:5432/skyvern",
+ ],
+ )
+
+ assert result.exit_code == 0
+ assert calls
+ call = calls[0]
+ assert call["no_postgres"] is False
+ assert call["mode"] == "local"
+ assert call["skip_llm_setup"] is True
+ assert call["configure_mcp"] is False
+ assert call["browser_type"] == "chromium-headless"
+ assert call["analytics_id"] == "anonymous"
+ assert call["return_result"] is True
+
+
+def test_quickstart_non_interactive_without_database_string_skips_postgres_prompt(monkeypatch) -> None:
+ calls: list[dict] = []
+
+ monkeypatch.setattr("skyvern.cli.quickstart._has_server_quickstart_extra", lambda: True)
+ monkeypatch.setattr("skyvern.cli.quickstart.check_docker_compose_file", lambda: False)
+ monkeypatch.setattr("skyvern.cli.quickstart._run_server_quickstart", lambda **kwargs: calls.append(kwargs))
+ monkeypatch.setattr(
+ "skyvern.cli.quickstart.Confirm.ask",
+ lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not prompt")),
+ )
+
+ result = CliRunner().invoke(quickstart_app, ["--non-interactive"])
+
+ assert result.exit_code == 0
+ assert "Non-interactive quickstart will not prompt to start PostgreSQL" in result.output
+ assert "--database-string" in result.output
+ assert calls
+ call = calls[0]
+ assert call["no_postgres"] is True
+ assert call["database_string"] == ""
+ assert call["skip_llm_setup"] is True
+ assert call["configure_mcp"] is False
+ assert call["browser_type"] == "chromium-headless"
+ assert call["analytics_id"] == "anonymous"
+ assert call["start_services_now"] is False
diff --git a/tests/unit/test_workflow_copilot_prompt_injection.py b/tests/unit/test_workflow_copilot_prompt_injection.py
index 1164c7453..f76bc1bae 100644
--- a/tests/unit/test_workflow_copilot_prompt_injection.py
+++ b/tests/unit/test_workflow_copilot_prompt_injection.py
@@ -404,6 +404,39 @@ class TestBuildUserContext:
)
assert "USER WORKFLOW CHANGES SINCE LAST COPILOT TURN" not in rendered
+ def test_repeated_reply_warning_slot_renders_when_present(self) -> None:
+ rendered = _build_user_context(
+ workflow_yaml="title: t",
+ chat_history_text="",
+ global_llm_context="",
+ debug_run_info_text="",
+ user_message="hello",
+ repeated_reply_warning="repeated_reply_detected: your last 2 replies were near-identical.",
+ )
+ assert "REPEATED REPLY WARNING" in rendered
+ assert "repeated_reply_detected" in rendered
+
+ def test_repeated_reply_warning_slot_omitted_when_empty(self) -> None:
+ rendered = _build_user_context(
+ workflow_yaml="title: t",
+ chat_history_text="",
+ global_llm_context="",
+ debug_run_info_text="",
+ user_message="hello",
+ )
+ assert "REPEATED REPLY WARNING" not in rendered
+
+ def test_repeated_reply_warning_is_fence_escaped(self) -> None:
+ rendered = _build_user_context(
+ workflow_yaml="",
+ chat_history_text="",
+ global_llm_context="",
+ debug_run_info_text="",
+ user_message="hello",
+ repeated_reply_warning="``` injected ```",
+ )
+ assert "``` injected ```" not in rendered
+
def test_workflow_summary_indexes_block_labels_and_error_mappings(self) -> None:
workflow_yaml = """
title: Invoice workflow