Skip to content

Automate browser based workflows with AI

fix(SKY-9430): bypass parse_api_response for reviewer LLM calls (#5781)

pedrohsdbd12571e64f7d
diff --git a/docs/developers/self-hosted/docker.mdx b/docs/developers/self-hosted/docker.mdx
index bcb28d3c2..d0c60e9f0 100644
--- a/docs/developers/self-hosted/docker.mdx
+++ b/docs/developers/self-hosted/docker.mdx
@@ -170,22 +170,6 @@ Docker Compose mounts several directories for persistent storage:
The `.env` file controls the Skyvern server. Here are the most important variables grouped by purpose.
-### Environment files
-
-`docker-compose.yml` uses TWO sources for service environment:
-
-1. **Inline `environment:` block** — compose-network values that depend on the docker network topology. Examples: `DATABASE_STRING=postgresql+psycopg://skyvern:skyvern@postgres:5432/skyvern` (the `postgres` hostname only resolves inside the compose network), `BROWSER_TYPE`, `ENABLE_CODE_BLOCK`.
-
-2. **`env_file: .env`** — user secrets (LLM API keys, etc.).
-
-**Do not move `DATABASE_STRING` from compose into `.env`.** The `.env.example` shipped with the repo uses a `localhost` host that points at the backend container itself when used inside compose — moving that value into `.env` will break the database connection.
-
-If you have an existing `.env` from a pre-1.0.32 `skyvern quickstart` run, it may contain a leftover `DATABASE_STRING=postgresql+psycopg://skyvern@localhost/skyvern` line. Remove it:
-
-```bash
-sed -i.bak '/^DATABASE_STRING.*localhost/d' .env
-```
-
### LLM Configuration
Configure at least one LLM provider. See [LLM Configuration](/developers/self-hosted/llm-configuration) for all providers.
diff --git a/docs/developers/self-hosted/overview.mdx b/docs/developers/self-hosted/overview.mdx
index d5ed59e77..ebd0db90d 100644
--- a/docs/developers/self-hosted/overview.mdx
+++ b/docs/developers/self-hosted/overview.mdx
@@ -84,9 +84,7 @@ Before deploying, ensure you have:
</Step>
</Steps>
-PostgreSQL 14+ is included in the Docker Compose setup. If you prefer an external database, configure `DATABASE_STRING` to point to your own instance.
-
-For the `pip install skyvern` path (Option A in the README), the default is a SQLite database at `~/.skyvern/data.db` — zero-config for local dev. To opt into Postgres for the pip path, run `skyvern quickstart --database-string=postgresql+psycopg://user:pass@host:5432/dbname`.
+PostgreSQL 14+ is included in the Docker Compose setup. If you prefer an external database, you can configure `DATABASE_STRING` to point to your own instance.
## Choose your deployment method
diff --git a/pyproject.toml b/pyproject.toml
index feff2253e..647c441f1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "skyvern"
-version = "1.0.31"
+version = "1.0.32"
description = ""
authors = [{ name = "Skyvern AI", email = "[email protected]" }]
requires-python = ">=3.11,<3.14"
diff --git a/skyvern/cli/quickstart.py b/skyvern/cli/quickstart.py
index 52482838a..50c8767d6 100644
--- a/skyvern/cli/quickstart.py
+++ b/skyvern/cli/quickstart.py
@@ -1,6 +1,7 @@
"""Quickstart command for Skyvern CLI."""
import asyncio
+import shutil
import subprocess
from pathlib import Path
@@ -70,6 +71,73 @@ def check_postgres_container_conflict() -> bool:
return False
+_COMPOSE_DATABASE_STRING = "postgresql+psycopg://skyvern:skyvern@postgres:5432/skyvern"
+
+
+def _bootstrap_compose_env_files() -> None:
+ """Copy `.env.example` and `skyvern-frontend/.env.example` into place when missing, and rewrite a localhost-pointing `DATABASE_STRING` to the compose-network value."""
+ bootstrapped: list[tuple[str, str]] = []
+
+ backend_env = Path(".env")
+ backend_example = Path(".env.example")
+ if not backend_env.exists() and backend_example.exists():
+ shutil.copyfile(backend_example, backend_env)
+ bootstrapped.append((str(backend_env), "edit it to set your LLM API keys before continuing"))
+
+ frontend_env = Path("skyvern-frontend/.env")
+ frontend_example = Path("skyvern-frontend/.env.example")
+ if not frontend_env.exists() and frontend_example.exists():
+ shutil.copyfile(frontend_example, frontend_env)
+ bootstrapped.append((str(frontend_env), "no edits required"))
+
+ if bootstrapped:
+ console.print(
+ Panel(
+ "[green]Created from .env.example:[/green]\n"
+ + "\n".join(f" • [cyan]{path}[/cyan] — {note}" for path, note in bootstrapped),
+ border_style="green",
+ )
+ )
+
+ if not backend_env.exists():
+ return
+
+ content = backend_env.read_text()
+ if "DATABASE_STRING" not in content or "localhost" not in content:
+ return
+
+ bad_lines = [
+ line for line in content.splitlines() if line.strip().startswith("DATABASE_STRING") and "localhost" in line
+ ]
+ if not bad_lines:
+ return
+
+ console.print(
+ Panel(
+ "[bold yellow]Warning:[/bold yellow] Your [cyan].env[/cyan] sets [bold]DATABASE_STRING[/bold] to a "
+ "[yellow]localhost[/yellow] URL. Inside the docker compose network that points at the backend "
+ "container, not the postgres service. Update it to:\n"
+ f" [green]{_COMPOSE_DATABASE_STRING}[/green]",
+ border_style="yellow",
+ )
+ )
+ if not Confirm.ask("Update DATABASE_STRING in .env now?", default=True):
+ return
+
+ replaced = False
+ new_lines: list[str] = []
+ for line in content.splitlines():
+ if line.strip().startswith("DATABASE_STRING") and "localhost" in line:
+ if not replaced:
+ new_lines.append(f'DATABASE_STRING="{_COMPOSE_DATABASE_STRING}"')
+ replaced = True
+ continue
+ new_lines.append(line)
+
+ backend_env.write_text("\n".join(new_lines) + "\n")
+ console.print("✅ [green]Updated DATABASE_STRING for the compose network.[/green]")
+
+
def run_docker_compose_setup() -> None:
"""Run the Docker Compose setup for Skyvern."""
console.print("\n[bold blue]Setting up Skyvern with Docker Compose...[/bold blue]")
@@ -105,6 +173,8 @@ def run_docker_compose_setup() -> None:
)
raise typer.Exit(0)
+ _bootstrap_compose_env_files()
+
# Configure LLM provider
console.print("\n[bold blue]Step 1: Configure LLM Provider[/bold blue]")
setup_llm_providers()
diff --git a/skyvern/client/__init__.py b/skyvern/client/__init__.py
index 5211c3a5d..c4480c924 100644
--- a/skyvern/client/__init__.py
+++ b/skyvern/client/__init__.py
@@ -168,6 +168,7 @@ if typing.TYPE_CHECKING:
ForLoopBlockLoopBlocksItem_UploadToS3,
ForLoopBlockLoopBlocksItem_Validation,
ForLoopBlockLoopBlocksItem_Wait,
+ ForLoopBlockLoopBlocksItem_WhileLoop,
ForLoopBlockLoopBlocksItem_WorkflowTrigger,
ForLoopBlockLoopOver,
ForLoopBlockLoopOver_AwsSecret,
@@ -434,6 +435,63 @@ if typing.TYPE_CHECKING:
WaitBlockParametersItem_Output,
WaitBlockParametersItem_Workflow,
WaitBlockYaml,
+ WhileLoopBlock,
+ WhileLoopBlockCondition,
+ WhileLoopBlockCondition_Jinja2Template,
+ WhileLoopBlockCondition_Prompt,
+ WhileLoopBlockLoopBlocksItem,
+ WhileLoopBlockLoopBlocksItem_Action,
+ WhileLoopBlockLoopBlocksItem_Code,
+ WhileLoopBlockLoopBlocksItem_Conditional,
+ WhileLoopBlockLoopBlocksItem_DownloadToS3,
+ WhileLoopBlockLoopBlocksItem_Extraction,
+ WhileLoopBlockLoopBlocksItem_FileDownload,
+ WhileLoopBlockLoopBlocksItem_FileUpload,
+ WhileLoopBlockLoopBlocksItem_FileUrlParser,
+ WhileLoopBlockLoopBlocksItem_ForLoop,
+ WhileLoopBlockLoopBlocksItem_GotoUrl,
+ WhileLoopBlockLoopBlocksItem_HttpRequest,
+ WhileLoopBlockLoopBlocksItem_HumanInteraction,
+ WhileLoopBlockLoopBlocksItem_Login,
+ WhileLoopBlockLoopBlocksItem_Navigation,
+ WhileLoopBlockLoopBlocksItem_PdfParser,
+ WhileLoopBlockLoopBlocksItem_PrintPage,
+ WhileLoopBlockLoopBlocksItem_SendEmail,
+ WhileLoopBlockLoopBlocksItem_Task,
+ WhileLoopBlockLoopBlocksItem_TaskV2,
+ WhileLoopBlockLoopBlocksItem_TextPrompt,
+ WhileLoopBlockLoopBlocksItem_UploadToS3,
+ WhileLoopBlockLoopBlocksItem_Validation,
+ WhileLoopBlockLoopBlocksItem_Wait,
+ WhileLoopBlockLoopBlocksItem_WhileLoop,
+ WhileLoopBlockLoopBlocksItem_WorkflowTrigger,
+ WhileLoopBlockYaml,
+ WhileLoopBlockYamlLoopBlocksItem,
+ WhileLoopBlockYamlLoopBlocksItem_Action,
+ WhileLoopBlockYamlLoopBlocksItem_Code,
+ WhileLoopBlockYamlLoopBlocksItem_Conditional,
+ WhileLoopBlockYamlLoopBlocksItem_DownloadToS3,
+ WhileLoopBlockYamlLoopBlocksItem_Extraction,
+ WhileLoopBlockYamlLoopBlocksItem_FileDownload,
+ WhileLoopBlockYamlLoopBlocksItem_FileUpload,
+ WhileLoopBlockYamlLoopBlocksItem_FileUrlParser,
+ WhileLoopBlockYamlLoopBlocksItem_ForLoop,
+ WhileLoopBlockYamlLoopBlocksItem_GotoUrl,
+ WhileLoopBlockYamlLoopBlocksItem_HttpRequest,
+ WhileLoopBlockYamlLoopBlocksItem_HumanInteraction,
+ WhileLoopBlockYamlLoopBlocksItem_Login,
+ WhileLoopBlockYamlLoopBlocksItem_Navigation,
+ WhileLoopBlockYamlLoopBlocksItem_PdfParser,
+ WhileLoopBlockYamlLoopBlocksItem_PrintPage,
+ WhileLoopBlockYamlLoopBlocksItem_SendEmail,
+ WhileLoopBlockYamlLoopBlocksItem_Task,
+ WhileLoopBlockYamlLoopBlocksItem_TaskV2,
+ WhileLoopBlockYamlLoopBlocksItem_TextPrompt,
+ WhileLoopBlockYamlLoopBlocksItem_UploadToS3,
+ WhileLoopBlockYamlLoopBlocksItem_Validation,
+ WhileLoopBlockYamlLoopBlocksItem_Wait,
+ WhileLoopBlockYamlLoopBlocksItem_WhileLoop,
+ WhileLoopBlockYamlLoopBlocksItem_WorkflowTrigger,
Workflow,
WorkflowCreateYamlRequest,
WorkflowCreateYamlRequestProxyLocation,
@@ -462,6 +520,7 @@ if typing.TYPE_CHECKING:
WorkflowDefinitionBlocksItem_UploadToS3,
WorkflowDefinitionBlocksItem_Validation,
WorkflowDefinitionBlocksItem_Wait,
+ WorkflowDefinitionBlocksItem_WhileLoop,
WorkflowDefinitionBlocksItem_WorkflowTrigger,
WorkflowDefinitionParametersItem,
WorkflowDefinitionParametersItem_AwsSecret,
@@ -500,6 +559,7 @@ if typing.TYPE_CHECKING:
WorkflowDefinitionYamlBlocksItem_UploadToS3,
WorkflowDefinitionYamlBlocksItem_Validation,
WorkflowDefinitionYamlBlocksItem_Wait,
+ WorkflowDefinitionYamlBlocksItem_WhileLoop,
WorkflowDefinitionYamlBlocksItem_WorkflowTrigger,
WorkflowDefinitionYamlParametersItem,
WorkflowDefinitionYamlParametersItem_AwsSecret,
@@ -724,6 +784,7 @@ _dynamic_imports: typing.Dict[str, str] = {
"ForLoopBlockLoopBlocksItem_UploadToS3": ".types",
"ForLoopBlockLoopBlocksItem_Validation": ".types",
"ForLoopBlockLoopBlocksItem_Wait": ".types",
+ "ForLoopBlockLoopBlocksItem_WhileLoop": ".types",
"ForLoopBlockLoopBlocksItem_WorkflowTrigger": ".types",
"ForLoopBlockLoopOver": ".types",
"ForLoopBlockLoopOver_AwsSecret": ".types",
@@ -996,6 +1057,63 @@ _dynamic_imports: typing.Dict[str, str] = {
"WaitBlockParametersItem_Output": ".types",
"WaitBlockParametersItem_Workflow": ".types",
"WaitBlockYaml": ".types",
+ "WhileLoopBlock": ".types",
+ "WhileLoopBlockCondition": ".types",
+ "WhileLoopBlockCondition_Jinja2Template": ".types",
+ "WhileLoopBlockCondition_Prompt": ".types",
+ "WhileLoopBlockLoopBlocksItem": ".types",
+ "WhileLoopBlockLoopBlocksItem_Action": ".types",
+ "WhileLoopBlockLoopBlocksItem_Code": ".types",
+ "WhileLoopBlockLoopBlocksItem_Conditional": ".types",
+ "WhileLoopBlockLoopBlocksItem_DownloadToS3": ".types",
+ "WhileLoopBlockLoopBlocksItem_Extraction": ".types",
+ "WhileLoopBlockLoopBlocksItem_FileDownload": ".types",
+ "WhileLoopBlockLoopBlocksItem_FileUpload": ".types",
+ "WhileLoopBlockLoopBlocksItem_FileUrlParser": ".types",
+ "WhileLoopBlockLoopBlocksItem_ForLoop": ".types",
+ "WhileLoopBlockLoopBlocksItem_GotoUrl": ".types",
+ "WhileLoopBlockLoopBlocksItem_HttpRequest": ".types",
+ "WhileLoopBlockLoopBlocksItem_HumanInteraction": ".types",
+ "WhileLoopBlockLoopBlocksItem_Login": ".types",
+ "WhileLoopBlockLoopBlocksItem_Navigation": ".types",
+ "WhileLoopBlockLoopBlocksItem_PdfParser": ".types",
+ "WhileLoopBlockLoopBlocksItem_PrintPage": ".types",
+ "WhileLoopBlockLoopBlocksItem_SendEmail": ".types",
+ "WhileLoopBlockLoopBlocksItem_Task": ".types",
+ "WhileLoopBlockLoopBlocksItem_TaskV2": ".types",
+ "WhileLoopBlockLoopBlocksItem_TextPrompt": ".types",
+ "WhileLoopBlockLoopBlocksItem_UploadToS3": ".types",
+ "WhileLoopBlockLoopBlocksItem_Validation": ".types",
+ "WhileLoopBlockLoopBlocksItem_Wait": ".types",
+ "WhileLoopBlockLoopBlocksItem_WhileLoop": ".types",
+ "WhileLoopBlockLoopBlocksItem_WorkflowTrigger": ".types",
+ "WhileLoopBlockYaml": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Action": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Code": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Conditional": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_DownloadToS3": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Extraction": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_FileDownload": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_FileUpload": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_FileUrlParser": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_ForLoop": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_GotoUrl": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_HttpRequest": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_HumanInteraction": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Login": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Navigation": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_PdfParser": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_PrintPage": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_SendEmail": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Task": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_TaskV2": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_TextPrompt": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_UploadToS3": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Validation": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_Wait": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_WhileLoop": ".types",
+ "WhileLoopBlockYamlLoopBlocksItem_WorkflowTrigger": ".types",
"Workflow": ".types",
"WorkflowCreateYamlRequest": ".types",
"WorkflowCreateYamlRequestProxyLocation": ".types",
@@ -1024,6 +1142,7 @@ _dynamic_imports: typing.Dict[str, str] = {
"WorkflowDefinitionBlocksItem_UploadToS3": ".types",
"WorkflowDefinitionBlocksItem_Validation": ".types",
"WorkflowDefinitionBlocksItem_Wait": ".types",
+ "WorkflowDefinitionBlocksItem_WhileLoop": ".types",
"WorkflowDefinitionBlocksItem_WorkflowTrigger": ".types",
"WorkflowDefinitionParametersItem": ".types",
"WorkflowDefinitionParametersItem_AwsSecret": ".types",
@@ -1062,6 +1181,7 @@ _dynamic_imports: typing.Dict[str, str] = {
"WorkflowDefinitionYamlBlocksItem_UploadToS3": ".types",
"WorkflowDefinitionYamlBlocksItem_Validation": ".types",
"WorkflowDefinitionYamlBlocksItem_Wait": ".types",
+ "WorkflowDefinitionYamlBlocksItem_WhileLoop": ".types",
"WorkflowDefinitionYamlBlocksItem_WorkflowTrigger": ".types",
"WorkflowDefinitionYamlParametersItem": ".types",
"WorkflowDefinitionYamlParametersItem_AwsSecret": ".types",
@@ -1307,6 +1427,7 @@ __all__ = [
"ForLoopBlockLoopBlocksItem_UploadToS3",
"ForLoopBlockLoopBlocksItem_Validation",
"ForLoopBlockLoopBlocksItem_Wait",
+ "ForLoopBlockLoopBlocksItem_WhileLoop",
"ForLoopBlockLoopBlocksItem_WorkflowTrigger",
"ForLoopBlockLoopOver",
"ForLoopBlockLoopOver_AwsSecret",
@@ -1579,6 +1700,63 @@ __all__ = [
"WaitBlockParametersItem_Output",
"WaitBlockParametersItem_Workflow",
"WaitBlockYaml",
+ "WhileLoopBlock",
+ "WhileLoopBlockCondition",
+ "WhileLoopBlockCondition_Jinja2Template",
+ "WhileLoopBlockCondition_Prompt",
+ "WhileLoopBlockLoopBlocksItem",
+ "WhileLoopBlockLoopBlocksItem_Action",
+ "WhileLoopBlockLoopBlocksItem_Code",
+ "WhileLoopBlockLoopBlocksItem_Conditional",
+ "WhileLoopBlockLoopBlocksItem_DownloadToS3",
+ "WhileLoopBlockLoopBlocksItem_Extraction",
+ "WhileLoopBlockLoopBlocksItem_FileDownload",
+ "WhileLoopBlockLoopBlocksItem_FileUpload",
+ "WhileLoopBlockLoopBlocksItem_FileUrlParser",
+ "WhileLoopBlockLoopBlocksItem_ForLoop",
+ "WhileLoopBlockLoopBlocksItem_GotoUrl",
+ "WhileLoopBlockLoopBlocksItem_HttpRequest",
+ "WhileLoopBlockLoopBlocksItem_HumanInteraction",
+ "WhileLoopBlockLoopBlocksItem_Login",
+ "WhileLoopBlockLoopBlocksItem_Navigation",
+ "WhileLoopBlockLoopBlocksItem_PdfParser",
+ "WhileLoopBlockLoopBlocksItem_PrintPage",
+ "WhileLoopBlockLoopBlocksItem_SendEmail",
+ "WhileLoopBlockLoopBlocksItem_Task",
+ "WhileLoopBlockLoopBlocksItem_TaskV2",
+ "WhileLoopBlockLoopBlocksItem_TextPrompt",
+ "WhileLoopBlockLoopBlocksItem_UploadToS3",
+ "WhileLoopBlockLoopBlocksItem_Validation",
+ "WhileLoopBlockLoopBlocksItem_Wait",
+ "WhileLoopBlockLoopBlocksItem_WhileLoop",
+ "WhileLoopBlockLoopBlocksItem_WorkflowTrigger",
+ "WhileLoopBlockYaml",
+ "WhileLoopBlockYamlLoopBlocksItem",
+ "WhileLoopBlockYamlLoopBlocksItem_Action",
+ "WhileLoopBlockYamlLoopBlocksItem_Code",
+ "WhileLoopBlockYamlLoopBlocksItem_Conditional",
+ "WhileLoopBlockYamlLoopBlocksItem_DownloadToS3",
+ "WhileLoopBlockYamlLoopBlocksItem_Extraction",
+ "WhileLoopBlockYamlLoopBlocksItem_FileDownload",
+ "WhileLoopBlockYamlLoopBlocksItem_FileUpload",
+ "WhileLoopBlockYamlLoopBlocksItem_FileUrlParser",
+ "WhileLoopBlockYamlLoopBlocksItem_ForLoop",
+ "WhileLoopBlockYamlLoopBlocksItem_GotoUrl",
+ "WhileLoopBlockYamlLoopBlocksItem_HttpRequest",
+ "WhileLoopBlockYamlLoopBlocksItem_HumanInteraction",
+ "WhileLoopBlockYamlLoopBlocksItem_Login",
+ "WhileLoopBlockYamlLoopBlocksItem_Navigation",
+ "WhileLoopBlockYamlLoopBlocksItem_PdfParser",
+ "WhileLoopBlockYamlLoopBlocksItem_PrintPage",
+ "WhileLoopBlockYamlLoopBlocksItem_SendEmail",
+ "WhileLoopBlockYamlLoopBlocksItem_Task",
+ "WhileLoopBlockYamlLoopBlocksItem_TaskV2",
+ "WhileLoopBlockYamlLoopBlocksItem_TextPrompt",
+ "WhileLoopBlockYamlLoopBlocksItem_UploadToS3",
+ "WhileLoopBlockYamlLoopBlocksItem_Validation",
+ "WhileLoopBlockYamlLoopBlocksItem_Wait",
+ "WhileLoopBlockYamlLoopBlocksItem_WhileLoop",
+ "WhileLoopBlockYamlLoopBlocksItem_WorkflowTrigger",
"Workflow",
"WorkflowCreateYamlRequest",
"WorkflowCreateYamlRequestProxyLocation",
@@ -1607,6 +1785,7 @@ __all__ = [
"WorkflowDefinitionBlocksItem_UploadToS3",
"WorkflowDefinitionBlocksItem_Validation",
"WorkflowDefinitionBlocksItem_Wait",
+ "WorkflowDefinitionBlocksItem_WhileLoop",
"WorkflowDefinitionBlocksItem_WorkflowTrigger",
"WorkflowDefinitionParametersItem",
"WorkflowDefinitionParametersItem_AwsSecret",
@@ -1645,6 +1824,7 @@ __all__ = [
"WorkflowDefinitionYamlBlocksItem_UploadToS3",
"WorkflowDefinitionYamlBlocksItem_Validation",
"WorkflowDefinitionYamlBlocksItem_Wait",
+ "WorkflowDefinitionYamlBlocksItem_WhileLoop",
"WorkflowDefinitionYamlBlocksItem_WorkflowTrigger",
"WorkflowDefinitionYamlParametersItem",
"WorkflowDefinitionYamlParametersItem_AwsSecret",
diff --git a/skyvern/client/core/client_wrapper.py b/skyvern/client/core/client_wrapper.py
index 222726377..16a2916da 100644
--- a/skyvern/client/core/client_wrapper.py
+++ b/skyvern/client/core/client_wrapper.py
@@ -22,10 +22,10 @@ class BaseClientWrapper:
def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
- "User-Agent": "skyvern/1.0.31",
+ "User-Agent": "skyvern/1.0.32",
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "skyvern",
- "X-Fern-SDK-Version": "1.0.31",
+ "X-Fern-SDK-Version": "1.0.32",
**(self.get_custom_headers() or {}),
}
if self._api_key is not None:
diff --git a/skyvern/client/types/__init__.py b/skyvern/client/types/__init__.py
index 38799a4df..813f333b8 100644
--- a/skyvern/client/types/__init__.py
+++ b/skyvern/client/types/__init__.py
@@ -224,7 +224,6 @@ if typing.TYPE_CHECKING:
ForLoopBlockYamlLoopBlocksItem_UploadToS3,
ForLoopBlockYamlLoopBlocksItem_Validation,
ForLoopBlockYamlLoopBlocksItem_Wait,
- ForLoopBlockYamlLoopBlocksItem_WhileLoop,
ForLoopBlockYamlLoopBlocksItem_WorkflowTrigger,
)
from .geo_target import GeoTarget
@@ -872,7 +871,6 @@ _dynamic_imports: typing.Dict[str, str] = {
"ForLoopBlockYamlLoopBlocksItem_UploadToS3": ".for_loop_block_yaml_loop_blocks_item",
"ForLoopBlockYamlLoopBlocksItem_Validation": ".for_loop_block_yaml_loop_blocks_item",
"ForLoopBlockYamlLoopBlocksItem_Wait": ".for_loop_block_yaml_loop_blocks_item",
- "ForLoopBlockYamlLoopBlocksItem_WhileLoop": ".for_loop_block_yaml_loop_blocks_item",
"ForLoopBlockYamlLoopBlocksItem_WorkflowTrigger": ".for_loop_block_yaml_loop_blocks_item",
"GeoTarget": ".geo_target",
"GetRunResponse": ".get_run_response",
@@ -1503,7 +1501,6 @@ __all__ = [
"ForLoopBlockYamlLoopBlocksItem_UploadToS3",
"ForLoopBlockYamlLoopBlocksItem_Validation",
"ForLoopBlockYamlLoopBlocksItem_Wait",
- "ForLoopBlockYamlLoopBlocksItem_WhileLoop",
"ForLoopBlockYamlLoopBlocksItem_WorkflowTrigger",
"GeoTarget",
"GetRunResponse",
diff --git a/skyvern/client/types/file_parser_block_yaml.py b/skyvern/client/types/file_parser_block_yaml.py
index fea8c7a9c..16468a2ec 100644
--- a/skyvern/client/types/file_parser_block_yaml.py
+++ b/skyvern/client/types/file_parser_block_yaml.py
@@ -22,7 +22,7 @@ class FileParserBlockYaml(UniversalBaseModel):
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
next_loop_on_failure: typing.Optional[bool] = None
file_url: str
- file_type: FileType
+ file_type: typing.Optional[FileType] = None
json_schema: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
if IS_PYDANTIC_V2:
diff --git a/skyvern/client/types/for_loop_block.py b/skyvern/client/types/for_loop_block.py
index 30c2f5cc1..ae300de14 100644
--- a/skyvern/client/types/for_loop_block.py
+++ b/skyvern/client/types/for_loop_block.py
@@ -45,5 +45,6 @@ class ForLoopBlock(UniversalBaseModel):
from .context_parameter import ContextParameter # noqa: E402, F401, I001
from .for_loop_block_loop_blocks_item import ForLoopBlockLoopBlocksItem # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
update_forward_refs(ForLoopBlock)
diff --git a/skyvern/client/types/for_loop_block_loop_blocks_item.py b/skyvern/client/types/for_loop_block_loop_blocks_item.py
index 4d64a8050..3fa623517 100644
--- a/skyvern/client/types/for_loop_block_loop_blocks_item.py
+++ b/skyvern/client/types/for_loop_block_loop_blocks_item.py
@@ -304,9 +304,6 @@ class ForLoopBlockLoopBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
-
-
class ForLoopBlockLoopBlocksItem_GotoUrl(UniversalBaseModel):
block_type: typing.Literal["goto_url"] = "goto_url"
label: str
@@ -755,21 +752,18 @@ class ForLoopBlockLoopBlocksItem_Wait(UniversalBaseModel):
extra = pydantic.Extra.allow
-class ForLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
- block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
+class ForLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
+ block_type: typing.Literal["while_loop"] = "while_loop"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- workflow_permanent_id: str
- payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- wait_for_completion: typing.Optional[bool] = None
- browser_session_id: typing.Optional[str] = None
- use_parent_browser_session: typing.Optional[bool] = None
- parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
+ loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
+ condition: WhileLoopBlockCondition
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -781,8 +775,8 @@ class ForLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class ForLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
+class ForLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
+ block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
@@ -790,8 +784,12 @@ class ForLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["ForLoopBlockLoopBlocksItem"]
- condition: WhileLoopBlockCondition
+ workflow_permanent_id: str
+ payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ wait_for_completion: typing.Optional[bool] = None
+ browser_session_id: typing.Optional[str] = None
+ use_parent_browser_session: typing.Optional[bool] = None
+ parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -803,8 +801,6 @@ class ForLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .context_parameter import ContextParameter # noqa: E402, F401, I001
-
ForLoopBlockLoopBlocksItem = typing.Union[
ForLoopBlockLoopBlocksItem_Action,
ForLoopBlockLoopBlocksItem_Code,
@@ -832,6 +828,11 @@ ForLoopBlockLoopBlocksItem = typing.Union[
ForLoopBlockLoopBlocksItem_WhileLoop,
ForLoopBlockLoopBlocksItem_WorkflowTrigger,
]
+from .context_parameter import ContextParameter # noqa: E402, F401, I001
+from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
+from .while_loop_block_loop_blocks_item import WhileLoopBlockLoopBlocksItem # noqa: E402, F401, I001
+
update_forward_refs(ForLoopBlockLoopBlocksItem_Action)
update_forward_refs(ForLoopBlockLoopBlocksItem_Code)
update_forward_refs(ForLoopBlockLoopBlocksItem_Extraction)
diff --git a/skyvern/client/types/for_loop_block_yaml_loop_blocks_item.py b/skyvern/client/types/for_loop_block_yaml_loop_blocks_item.py
index 7a87b74ec..1cf196a7e 100644
--- a/skyvern/client/types/for_loop_block_yaml_loop_blocks_item.py
+++ b/skyvern/client/types/for_loop_block_yaml_loop_blocks_item.py
@@ -9,7 +9,6 @@ import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs
from ..core.serialization import FieldMetadata
from .branch_condition_yaml import BranchConditionYaml
-from .branch_criteria_yaml import BranchCriteriaYaml
from .extraction_block_yaml_data_schema import ExtractionBlockYamlDataSchema
from .file_storage_type import FileStorageType
from .file_type import FileType
@@ -79,9 +78,6 @@ class ForLoopBlockYamlLoopBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
-
-
class ForLoopBlockYamlLoopBlocksItem_Code(UniversalBaseModel):
block_type: typing.Literal["code"] = "code"
label: str
@@ -620,26 +616,6 @@ class ForLoopBlockYamlLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class ForLoopBlockYamlLoopBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
- label: str
- next_block_label: typing.Optional[str] = None
- continue_on_failure: typing.Optional[bool] = None
- model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["ForLoopBlockYamlLoopBlocksItem"]
- condition: BranchCriteriaYaml
-
- if IS_PYDANTIC_V2:
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
- else:
-
- class Config:
- frozen = True
- smart_union = True
- extra = pydantic.Extra.allow
-
-
ForLoopBlockYamlLoopBlocksItem = typing.Union[
ForLoopBlockYamlLoopBlocksItem_Task,
ForLoopBlockYamlLoopBlocksItem_ForLoop,
@@ -664,8 +640,8 @@ ForLoopBlockYamlLoopBlocksItem = typing.Union[
ForLoopBlockYamlLoopBlocksItem_HttpRequest,
ForLoopBlockYamlLoopBlocksItem_Conditional,
ForLoopBlockYamlLoopBlocksItem_PrintPage,
- ForLoopBlockYamlLoopBlocksItem_WhileLoop,
ForLoopBlockYamlLoopBlocksItem_WorkflowTrigger,
]
+from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+
update_forward_refs(ForLoopBlockYamlLoopBlocksItem_ForLoop)
-update_forward_refs(ForLoopBlockYamlLoopBlocksItem_WhileLoop)
diff --git a/skyvern/client/types/proxy_location.py b/skyvern/client/types/proxy_location.py
index 2525f6d1d..948c70a88 100644
--- a/skyvern/client/types/proxy_location.py
+++ b/skyvern/client/types/proxy_location.py
@@ -29,7 +29,6 @@ ProxyLocation = typing.Union[
"RESIDENTIAL_NL",
"RESIDENTIAL_PH",
"RESIDENTIAL_KR",
- "RESIDENTIAL_SA",
"RESIDENTIAL_ISP",
"NONE",
],
diff --git a/skyvern/client/types/while_loop_block.py b/skyvern/client/types/while_loop_block.py
index af4f30334..637da4566 100644
--- a/skyvern/client/types/while_loop_block.py
+++ b/skyvern/client/types/while_loop_block.py
@@ -11,6 +11,17 @@ from .while_loop_block_condition import WhileLoopBlockCondition
class WhileLoopBlock(UniversalBaseModel):
+ """
+ Loop block driven by a runtime condition. Iterates while ``condition`` evaluates truthy.
+
+ Top-of-loop semantics: the condition is evaluated *before* each iteration (including the
+ first). If the condition is false on the first check, the body never runs and the block
+ returns success with an empty output list.
+
+ Safety: the loop is capped at ``DEFAULT_MAX_LOOP_ITERATIONS`` (100). Reaching the cap is
+ treated as a failure so that a misbehaving condition can never spin forever.
+ """
+
label: str = pydantic.Field()
"""
Author-facing identifier for a block; unique within a workflow.
@@ -25,6 +36,7 @@ class WhileLoopBlock(UniversalBaseModel):
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
condition: WhileLoopBlockCondition
@@ -41,5 +53,6 @@ class WhileLoopBlock(UniversalBaseModel):
from .context_parameter import ContextParameter # noqa: E402, F401, I001
from .while_loop_block_loop_blocks_item import WhileLoopBlockLoopBlocksItem # noqa: E402, F401, I001
+from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
update_forward_refs(WhileLoopBlock)
diff --git a/skyvern/client/types/while_loop_block_loop_blocks_item.py b/skyvern/client/types/while_loop_block_loop_blocks_item.py
index fd62a87e0..4171c1349 100644
--- a/skyvern/client/types/while_loop_block_loop_blocks_item.py
+++ b/skyvern/client/types/while_loop_block_loop_blocks_item.py
@@ -288,7 +288,7 @@ class WhileLoopBlockLoopBlocksItem_ForLoop(UniversalBaseModel):
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
+ loop_blocks: typing.List["ForLoopBlockLoopBlocksItem"]
loop_over: typing.Optional[ForLoopBlockLoopOver] = None
loop_variable_reference: typing.Optional[str] = None
complete_if_empty: typing.Optional[bool] = None
@@ -304,9 +304,6 @@ class WhileLoopBlockLoopBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
-
-
class WhileLoopBlockLoopBlocksItem_GotoUrl(UniversalBaseModel):
block_type: typing.Literal["goto_url"] = "goto_url"
label: str
@@ -755,21 +752,18 @@ class WhileLoopBlockLoopBlocksItem_Wait(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WhileLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
- block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
+class WhileLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
+ block_type: typing.Literal["while_loop"] = "while_loop"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- workflow_permanent_id: str
- payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- wait_for_completion: typing.Optional[bool] = None
- browser_session_id: typing.Optional[str] = None
- use_parent_browser_session: typing.Optional[bool] = None
- parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
+ loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
+ condition: WhileLoopBlockCondition
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -781,8 +775,8 @@ class WhileLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WhileLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
+class WhileLoopBlockLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
+ block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
@@ -790,8 +784,12 @@ class WhileLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
- condition: WhileLoopBlockCondition
+ workflow_permanent_id: str
+ payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ wait_for_completion: typing.Optional[bool] = None
+ browser_session_id: typing.Optional[str] = None
+ use_parent_browser_session: typing.Optional[bool] = None
+ parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -803,8 +801,6 @@ class WhileLoopBlockLoopBlocksItem_WhileLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .context_parameter import ContextParameter # noqa: E402, F401, I001
-
WhileLoopBlockLoopBlocksItem = typing.Union[
WhileLoopBlockLoopBlocksItem_Action,
WhileLoopBlockLoopBlocksItem_Code,
@@ -832,6 +828,11 @@ WhileLoopBlockLoopBlocksItem = typing.Union[
WhileLoopBlockLoopBlocksItem_WhileLoop,
WhileLoopBlockLoopBlocksItem_WorkflowTrigger,
]
+from .context_parameter import ContextParameter # noqa: E402, F401, I001
+from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
+from .for_loop_block_loop_blocks_item import ForLoopBlockLoopBlocksItem # noqa: E402, F401, I001
+
update_forward_refs(WhileLoopBlockLoopBlocksItem_Action)
update_forward_refs(WhileLoopBlockLoopBlocksItem_Code)
update_forward_refs(WhileLoopBlockLoopBlocksItem_Extraction)
diff --git a/skyvern/client/types/while_loop_block_yaml.py b/skyvern/client/types/while_loop_block_yaml.py
index 76fcb45ee..f66ab4bdd 100644
--- a/skyvern/client/types/while_loop_block_yaml.py
+++ b/skyvern/client/types/while_loop_block_yaml.py
@@ -22,6 +22,7 @@ class WhileLoopBlockYaml(UniversalBaseModel):
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
loop_blocks: typing.List["WhileLoopBlockYamlLoopBlocksItem"]
condition: BranchCriteriaYaml
@@ -36,6 +37,7 @@ class WhileLoopBlockYaml(UniversalBaseModel):
extra = pydantic.Extra.allow
+from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
from .while_loop_block_yaml_loop_blocks_item import WhileLoopBlockYamlLoopBlocksItem # noqa: E402, F401, I001
update_forward_refs(WhileLoopBlockYaml)
diff --git a/skyvern/client/types/while_loop_block_yaml_loop_blocks_item.py b/skyvern/client/types/while_loop_block_yaml_loop_blocks_item.py
index c604507f9..3422548ee 100644
--- a/skyvern/client/types/while_loop_block_yaml_loop_blocks_item.py
+++ b/skyvern/client/types/while_loop_block_yaml_loop_blocks_item.py
@@ -63,7 +63,7 @@ class WhileLoopBlockYamlLoopBlocksItem_ForLoop(UniversalBaseModel):
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WhileLoopBlockYamlLoopBlocksItem"]
+ loop_blocks: typing.List["ForLoopBlockYamlLoopBlocksItem"]
loop_over_parameter_key: typing.Optional[str] = None
loop_variable_reference: typing.Optional[str] = None
complete_if_empty: typing.Optional[bool] = None
@@ -79,7 +79,25 @@ class WhileLoopBlockYamlLoopBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+class WhileLoopBlockYamlLoopBlocksItem_WhileLoop(UniversalBaseModel):
+ block_type: typing.Literal["while_loop"] = "while_loop"
+ label: str
+ next_block_label: typing.Optional[str] = None
+ continue_on_failure: typing.Optional[bool] = None
+ model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
+ next_loop_on_failure: typing.Optional[bool] = None
+ loop_blocks: typing.List["WhileLoopBlockYamlLoopBlocksItem"]
+ condition: BranchCriteriaYaml
+
+ if IS_PYDANTIC_V2:
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
+ else:
+
+ class Config:
+ frozen = True
+ smart_union = True
+ extra = pydantic.Extra.allow
class WhileLoopBlockYamlLoopBlocksItem_Code(UniversalBaseModel):
@@ -620,29 +638,10 @@ class WhileLoopBlockYamlLoopBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WhileLoopBlockYamlLoopBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
- label: str
- next_block_label: typing.Optional[str] = None
- continue_on_failure: typing.Optional[bool] = None
- model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WhileLoopBlockYamlLoopBlocksItem"]
- condition: BranchCriteriaYaml
-
- if IS_PYDANTIC_V2:
- model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
- else:
-
- class Config:
- frozen = True
- smart_union = True
- extra = pydantic.Extra.allow
-
-
WhileLoopBlockYamlLoopBlocksItem = typing.Union[
WhileLoopBlockYamlLoopBlocksItem_Task,
WhileLoopBlockYamlLoopBlocksItem_ForLoop,
+ WhileLoopBlockYamlLoopBlocksItem_WhileLoop,
WhileLoopBlockYamlLoopBlocksItem_Code,
WhileLoopBlockYamlLoopBlocksItem_TextPrompt,
WhileLoopBlockYamlLoopBlocksItem_DownloadToS3,
@@ -664,8 +663,11 @@ WhileLoopBlockYamlLoopBlocksItem = typing.Union[
WhileLoopBlockYamlLoopBlocksItem_HttpRequest,
WhileLoopBlockYamlLoopBlocksItem_Conditional,
WhileLoopBlockYamlLoopBlocksItem_PrintPage,
- WhileLoopBlockYamlLoopBlocksItem_WhileLoop,
WhileLoopBlockYamlLoopBlocksItem_WorkflowTrigger,
]
+from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml import WhileLoopBlockYaml # noqa: E402, F401, I001
+from .for_loop_block_yaml_loop_blocks_item import ForLoopBlockYamlLoopBlocksItem # noqa: E402, F401, I001
+
update_forward_refs(WhileLoopBlockYamlLoopBlocksItem_ForLoop)
update_forward_refs(WhileLoopBlockYamlLoopBlocksItem_WhileLoop)
diff --git a/skyvern/client/types/workflow.py b/skyvern/client/types/workflow.py
index 9b4af933e..3a341571f 100644
--- a/skyvern/client/types/workflow.py
+++ b/skyvern/client/types/workflow.py
@@ -57,5 +57,6 @@ class Workflow(UniversalBaseModel):
from .context_parameter import ContextParameter # noqa: E402, F401, I001
from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
update_forward_refs(Workflow)
diff --git a/skyvern/client/types/workflow_create_yaml_request.py b/skyvern/client/types/workflow_create_yaml_request.py
index e30c75e13..6c565ea55 100644
--- a/skyvern/client/types/workflow_create_yaml_request.py
+++ b/skyvern/client/types/workflow_create_yaml_request.py
@@ -46,5 +46,6 @@ class WorkflowCreateYamlRequest(UniversalBaseModel):
from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml import WhileLoopBlockYaml # noqa: E402, F401, I001
update_forward_refs(WorkflowCreateYamlRequest)
diff --git a/skyvern/client/types/workflow_definition.py b/skyvern/client/types/workflow_definition.py
index 55d611f8e..46e72413a 100644
--- a/skyvern/client/types/workflow_definition.py
+++ b/skyvern/client/types/workflow_definition.py
@@ -28,5 +28,6 @@ class WorkflowDefinition(UniversalBaseModel):
from .context_parameter import ContextParameter # noqa: E402, F401, I001
from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
update_forward_refs(WorkflowDefinition)
diff --git a/skyvern/client/types/workflow_definition_blocks_item.py b/skyvern/client/types/workflow_definition_blocks_item.py
index b7f8a85b0..5366365ed 100644
--- a/skyvern/client/types/workflow_definition_blocks_item.py
+++ b/skyvern/client/types/workflow_definition_blocks_item.py
@@ -304,7 +304,6 @@ class WorkflowDefinitionBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
from .for_loop_block_loop_blocks_item import ForLoopBlockLoopBlocksItem # noqa: E402, F401, I001
@@ -756,21 +755,18 @@ class WorkflowDefinitionBlocksItem_Wait(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WorkflowDefinitionBlocksItem_WorkflowTrigger(UniversalBaseModel):
- block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
+class WorkflowDefinitionBlocksItem_WhileLoop(UniversalBaseModel):
+ block_type: typing.Literal["while_loop"] = "while_loop"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- workflow_permanent_id: str
- payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- wait_for_completion: typing.Optional[bool] = None
- browser_session_id: typing.Optional[str] = None
- use_parent_browser_session: typing.Optional[bool] = None
- parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
+ loop_blocks: typing.List["WhileLoopBlockLoopBlocksItem"]
+ condition: WhileLoopBlockCondition
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -782,8 +778,13 @@ class WorkflowDefinitionBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WorkflowDefinitionBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
+from .for_loop_block import ForLoopBlock # noqa: E402, F401, I001
+from .while_loop_block import WhileLoopBlock # noqa: E402, F401, I001
+from .while_loop_block_loop_blocks_item import WhileLoopBlockLoopBlocksItem # noqa: E402, F401, I001
+
+
+class WorkflowDefinitionBlocksItem_WorkflowTrigger(UniversalBaseModel):
+ block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
label: str
next_block_label: typing.Optional[str] = None
output_parameter: OutputParameter
@@ -791,8 +792,12 @@ class WorkflowDefinitionBlocksItem_WhileLoop(UniversalBaseModel):
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
disable_cache: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WorkflowDefinitionBlocksItem"]
- condition: WhileLoopBlockCondition
+ workflow_permanent_id: str
+ payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ wait_for_completion: typing.Optional[bool] = None
+ browser_session_id: typing.Optional[str] = None
+ use_parent_browser_session: typing.Optional[bool] = None
+ parameters: typing.Optional[typing.List[WorkflowTriggerBlockParametersItem]] = None
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
diff --git a/skyvern/client/types/workflow_definition_yaml.py b/skyvern/client/types/workflow_definition_yaml.py
index b59071b12..23da01186 100644
--- a/skyvern/client/types/workflow_definition_yaml.py
+++ b/skyvern/client/types/workflow_definition_yaml.py
@@ -27,5 +27,6 @@ class WorkflowDefinitionYaml(UniversalBaseModel):
from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml import WhileLoopBlockYaml # noqa: E402, F401, I001
update_forward_refs(WorkflowDefinitionYaml)
diff --git a/skyvern/client/types/workflow_definition_yaml_blocks_item.py b/skyvern/client/types/workflow_definition_yaml_blocks_item.py
index e43eee71b..452775468 100644
--- a/skyvern/client/types/workflow_definition_yaml_blocks_item.py
+++ b/skyvern/client/types/workflow_definition_yaml_blocks_item.py
@@ -237,7 +237,6 @@ class WorkflowDefinitionYamlBlocksItem_ForLoop(UniversalBaseModel):
extra = pydantic.Extra.allow
-from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
from .for_loop_block_yaml_loop_blocks_item import ForLoopBlockYamlLoopBlocksItem # noqa: E402, F401, I001
@@ -597,19 +596,16 @@ class WorkflowDefinitionYamlBlocksItem_Wait(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WorkflowDefinitionYamlBlocksItem_WorkflowTrigger(UniversalBaseModel):
- block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
+class WorkflowDefinitionYamlBlocksItem_WhileLoop(UniversalBaseModel):
+ block_type: typing.Literal["while_loop"] = "while_loop"
label: str
next_block_label: typing.Optional[str] = None
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ ignore_workflow_system_prompt: typing.Optional[bool] = None
next_loop_on_failure: typing.Optional[bool] = None
- workflow_permanent_id: str
- payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
- wait_for_completion: typing.Optional[bool] = None
- browser_session_id: typing.Optional[str] = None
- use_parent_browser_session: typing.Optional[bool] = None
- parameter_keys: typing.Optional[typing.List[str]] = None
+ loop_blocks: typing.List["WhileLoopBlockYamlLoopBlocksItem"]
+ condition: BranchCriteriaYaml
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
@@ -621,15 +617,24 @@ class WorkflowDefinitionYamlBlocksItem_WorkflowTrigger(UniversalBaseModel):
extra = pydantic.Extra.allow
-class WorkflowDefinitionYamlBlocksItem_WhileLoop(UniversalBaseModel):
- block_type: typing.Literal["while_loop"] = "while_loop"
+from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml import WhileLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml_loop_blocks_item import WhileLoopBlockYamlLoopBlocksItem # noqa: E402, F401, I001
+
+
+class WorkflowDefinitionYamlBlocksItem_WorkflowTrigger(UniversalBaseModel):
+ block_type: typing.Literal["workflow_trigger"] = "workflow_trigger"
label: str
next_block_label: typing.Optional[str] = None
continue_on_failure: typing.Optional[bool] = None
model: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
next_loop_on_failure: typing.Optional[bool] = None
- loop_blocks: typing.List["WorkflowDefinitionYamlBlocksItem"]
- condition: BranchCriteriaYaml
+ workflow_permanent_id: str
+ payload: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
+ wait_for_completion: typing.Optional[bool] = None
+ browser_session_id: typing.Optional[str] = None
+ use_parent_browser_session: typing.Optional[bool] = None
+ parameter_keys: typing.Optional[typing.List[str]] = None
if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
diff --git a/skyvern/client/types/workflow_request.py b/skyvern/client/types/workflow_request.py
index bfe77684e..b21566e65 100644
--- a/skyvern/client/types/workflow_request.py
+++ b/skyvern/client/types/workflow_request.py
@@ -31,5 +31,6 @@ class WorkflowRequest(UniversalBaseModel):
from .for_loop_block_yaml import ForLoopBlockYaml # noqa: E402, F401, I001
+from .while_loop_block_yaml import WhileLoopBlockYaml # noqa: E402, F401, I001
update_forward_refs(WorkflowRequest)
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.py
index a7c07425d..cc48d2085 100644
--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py
+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py
@@ -1042,7 +1042,11 @@ class LLMAPIHandlerFactory:
await _persist_block_llm_cost(
workflow_run_block_id, organization_id, context, llm_cost, prompt_name
)
- parsed_response = parse_api_response(response, llm_config.add_assistant_prefix, force_dict)
+ if raw_response:
+ content = response.choices[0].message.content if response.choices else None
+ parsed_response = content or ""
+ else:
+ parsed_response = parse_api_response(response, llm_config.add_assistant_prefix, force_dict)
parsed_response_json = json.dumps(parsed_response, indent=2)
if should_persist_llm_artifacts:
if _should_bundle:
@@ -1574,7 +1578,11 @@ class LLMAPIHandlerFactory:
await _persist_block_llm_cost(
workflow_run_block_id, organization_id, context, llm_cost, prompt_name
)
- parsed_response = parse_api_response(response, llm_config.add_assistant_prefix, force_dict)
+ if raw_response:
+ content = response.choices[0].message.content if response.choices else None
+ parsed_response = content or ""
+ else:
+ parsed_response = parse_api_response(response, llm_config.add_assistant_prefix, force_dict)
parsed_response_json = json.dumps(parsed_response, indent=2)
if should_persist_llm_artifacts:
if _should_bundle:
diff --git a/skyvern/forge/sdk/copilot/agent.py b/skyvern/forge/sdk/copilot/agent.py
index 0b60a0142..369291483 100644
--- a/skyvern/forge/sdk/copilot/agent.py
+++ b/skyvern/forge/sdk/copilot/agent.py
@@ -265,17 +265,9 @@ _MAX_TURNS_REPLY_UNVALIDATED = (
_MAX_TURNS_REPLY_TESTED = (
"I've reached the maximum number of steps, but I have a tested draft for you. Accept it to save, or discard."
)
-_UNEXPECTED_ERROR_REPLY_DEFAULT = "An unexpected error occurred. Please try again."
-_UNEXPECTED_ERROR_REPLY_UNVALIDATED = (
- "I hit an unexpected issue before I could finish testing. I have a draft workflow you can keep — "
- "accept it to save (note: it hasn't been verified end-to-end), or discard."
-)
-_UNEXPECTED_ERROR_REPLY_TESTED = (
- "I hit an unexpected issue, but I have a tested draft for you. Accept it to save, or discard."
-)
-def _build_wip_exit_result(
+def _build_capacity_exit_result(
ctx: CopilotContext,
global_llm_context: str | None,
*,
@@ -283,7 +275,8 @@ def _build_wip_exit_result(
unvalidated_reply: str,
tested_reply: str,
) -> AgentResult:
- """Selected non-success exits surface the most recent successfully parsed workflow."""
+ """Capacity-exhausted exits (timeout, max-turns) surface the most recent
+ successfully-parsed workflow rather than discard the WIP."""
# ``last_test_ok=None`` covers both "test never ran" and "test ran with
# ambiguous output"; only the first case earns the carve-out (the REPLY
# path is more permissive because its reply text carries the context).
@@ -308,7 +301,7 @@ def _build_wip_exit_result(
def _build_timeout_exit_result(ctx: CopilotContext, global_llm_context: str | None) -> AgentResult:
- return _build_wip_exit_result(
+ return _build_capacity_exit_result(
ctx,
global_llm_context,
default_reply=_TIMEOUT_REPLY_DEFAULT,
@@ -318,7 +311,7 @@ def _build_timeout_exit_result(ctx: CopilotContext, global_llm_context: str | No
def _build_max_turns_exit_result(ctx: CopilotContext, global_llm_context: str | None) -> AgentResult:
- return _build_wip_exit_result(
+ return _build_capacity_exit_result(
ctx,
global_llm_context,
default_reply=_MAX_TURNS_REPLY_DEFAULT,
@@ -327,16 +320,6 @@ def _build_max_turns_exit_result(ctx: CopilotContext, global_llm_context: str |
)
-def _build_unexpected_error_exit_result(ctx: CopilotContext, global_llm_context: str | None) -> AgentResult:
- return _build_wip_exit_result(
- ctx,
- global_llm_context,
- default_reply=_UNEXPECTED_ERROR_REPLY_DEFAULT,
- unvalidated_reply=_UNEXPECTED_ERROR_REPLY_UNVALIDATED,
- tested_reply=_UNEXPECTED_ERROR_REPLY_TESTED,
- )
-
-
def _translate_to_agent_result(
result: RunResultStreaming,
ctx: CopilotContext,
@@ -695,7 +678,7 @@ async def run_copilot_agent(
)
except Exception as e:
LOG.error("Copilot agent error", error=str(e), exc_info=True)
- return _build_unexpected_error_exit_result(ctx, global_llm_context)
+ return _build_exit_result(ctx, "An unexpected error occurred. Please try again.", global_llm_context)
finally:
_copilot_model_name.reset(model_token)
session.close()
diff --git a/skyvern/services/script_reviewer.py b/skyvern/services/script_reviewer.py
index 04ed87f2c..c0faf1166 100644
--- a/skyvern/services/script_reviewer.py
+++ b/skyvern/services/script_reviewer.py
@@ -6,6 +6,7 @@ import json
import re
from typing import Literal, Sequence
+import json_repair
import libcst as cst
import structlog
@@ -464,14 +465,20 @@ class ScriptReviewer:
prompt_name="script-reviewer-conditional",
step=None,
organization_id=organization_id,
+ raw_response=True,
)
- code = self._extract_code_from_response(llm_response)
+ code = self._extract_code_from_response(
+ llm_response,
+ block_label=block_label,
+ prompt_name="script-reviewer-conditional",
+ )
if not code:
LOG.warning(
"ScriptReviewer: no code extracted for conditional",
block_label=block_label,
attempt=attempt,
+ prompt_name="script-reviewer-conditional",
)
if attempt >= max_attempts:
return None
@@ -493,6 +500,7 @@ class ScriptReviewer:
block_label=block_label,
attempt=attempt,
error=compile_error,
+ prompt_name="script-reviewer-conditional",
)
if attempt < max_attempts:
current_prompt = self._build_retry_prompt(code, compile_error, function_signature)
@@ -793,22 +801,29 @@ class ScriptReviewer:
prompt_name=template,
step=None,
organization_id=organization_id,
+ raw_response=True,
)
LOG.info(
"ScriptReviewer: LLM response received",
block_label=block_label,
attempt=attempt,
+ prompt_name=template,
response_type=type(llm_response).__name__,
response_snippet=str(llm_response)[:200],
)
- updated_code = self._extract_code_from_response(llm_response)
+ updated_code = self._extract_code_from_response(
+ llm_response,
+ block_label=block_label,
+ prompt_name=template,
+ )
if not updated_code:
LOG.warning(
"ScriptReviewer: no code extracted from response",
block_label=block_label,
attempt=attempt,
+ prompt_name=template,
response_snippet=str(llm_response)[:500],
)
if attempt >= max_attempts:
@@ -822,6 +837,7 @@ class ScriptReviewer:
"ScriptReviewer: compile error, retrying",
block_label=block_label,
attempt=attempt,
+ prompt_name=template,
error=compile_error,
code_snippet=updated_code[:300],
)
@@ -1212,83 +1228,113 @@ class ScriptReviewer:
return stripped
return "async def block_fn(page, context):"
- def _extract_code_from_response(self, response: dict | str | list | None) -> str | None:
- """Extract Python code from the LLM response.
-
- Strict parsing: expects either a JSON dict with a "code" key, or a markdown
- code block. Does NOT attempt to salvage malformed responses (lists, raw
- str() coercion) — those should fail and trigger a retry.
- """
- if not response:
- return None
-
- # Step 1: Get the text content from the response
- text = ""
- if isinstance(response, dict):
- # Direct "code" key (expected JSON format)
- code_value = response.get("code")
- if isinstance(code_value, str) and code_value.strip():
- return code_value.strip()
- # llm_response or updated_code keys
- text = response.get("updated_code", "") or response.get("llm_response", "")
- elif isinstance(response, str):
- text = response
- elif isinstance(response, list):
- # LLM returned a list — this is malformed. Do NOT salvage with str().
+ def _response_to_text(self, response: object) -> str:
+ if isinstance(response, str):
+ return response
+ if isinstance(response, list):
LOG.warning(
- "ScriptReviewer: LLM returned a list instead of dict/str, rejecting",
- response_type="list",
+ "ScriptReviewer: LLM returned a list, rejecting",
response_length=len(response),
)
- return None
- else:
- LOG.warning(
- "ScriptReviewer: unexpected response type, rejecting",
- response_type=type(response).__name__,
- )
- return None
+ return ""
+ if isinstance(response, dict):
+ choices = response.get("choices") or []
+ if choices:
+ content = choices[0].get("message", {}).get("content") if isinstance(choices[0], dict) else None
+ if isinstance(content, str):
+ return content
+ try:
+ return json.dumps(response)
+ except (TypeError, ValueError):
+ return ""
+ return ""
+ def _extract_code_from_response(
+ self,
+ response: object,
+ block_label: str | None = None,
+ prompt_name: str | None = None,
+ ) -> str | None:
+ if not response:
+ return None
+ text = self._response_to_text(response).strip()
if not text:
return None
- # Step 2: Try to parse text as JSON with a "code" key
- try:
- parsed = json.loads(text)
- if isinstance(parsed, dict):
- code_value = parsed.get("code")
- if isinstance(code_value, str) and code_value.strip():
- return code_value.strip()
- except (json.JSONDecodeError, ValueError):
- pass
-
- # Step 3: Extract from markdown code blocks
- if "```python" in text:
- start = text.index("```python") + len("```python")
- remaining = text[start:]
- end = remaining.find("```")
- if end != -1:
- code = remaining[:end].strip()
- else:
- code = remaining.strip()
- if "async def " in code:
- return code
- return None
+ if text == "CANNOT_CONVERT":
+ return text
if "```" in text:
start = text.index("```") + 3
remaining = text[start:]
end = remaining.find("```")
- if end != -1:
- code = remaining[:end].strip()
- else:
- code = remaining.strip()
- if "async def " in code:
+ code = remaining[:end] if end != -1 else remaining
+ for tag in ("python", "py", "json"):
+ if code.startswith(tag) and len(code) > len(tag) and code[len(tag)] in (" ", "\n", "\r"):
+ code = code[len(tag) :]
+ break
+ code = code.strip()
+ if code.startswith("{"):
+ # Fenced content is a JSON object — let json_repair handle it
+ # below so well-formed and malformed-Mode-A shapes both extract.
+ text = code
+ elif "async def " in code:
return code
- return None
+ else:
+ return None
- # Step 4: If text itself looks like a complete Python function, accept it
- if text.strip().startswith("async def "):
- return text.strip()
+ if text.startswith("async def "):
+ return text
+
+ try:
+ parsed = json_repair.loads(text)
+ except Exception:
+ parsed = None
+
+ if isinstance(parsed, dict):
+ code_value = parsed.get("code")
+ if isinstance(code_value, str) and code_value.strip():
+ code_str = code_value.strip()
+ if self._get_compile_error(code_str) is None:
+ return code_str
+ if code_str.startswith("async def ") and code_str.count("(") > code_str.count(")") and len(parsed) > 1:
+ # When the LLM emits a Python type annotation inside a JSON string with
+ # unescaped quotes — e.g. `{"code": "async def fn(page: T", "ctx": "U):..."}` —
+ # json_repair splits each `<param>: <Type>` pair into its own dict entry.
+ # Re-joining as `, key: value` reverses the split for the type-annotation
+ # pattern. compile-checked below; falls back to the truncated code on miss.
+ pieces = [code_str]
+ bail = False
+ for k, v in parsed.items():
+ if k == "code":
+ continue
+ if not isinstance(v, str):
+ bail = True
+ break
+ pieces.append(f", {k}: {v}")
+ if not bail:
+ reconstructed = "".join(pieces)
+ log_preview = [str(k)[:50] for k in list(parsed.keys())[:5]]
+ if self._get_compile_error(reconstructed) is None:
+ LOG.info(
+ "ScriptReviewer: malformed-dict recovery applied",
+ block_label=block_label,
+ prompt_name=prompt_name,
+ dict_key_count=len(parsed),
+ dict_key_preview=log_preview,
+ )
+ return reconstructed
+ LOG.warning(
+ "ScriptReviewer: malformed-dict recovery failed compile",
+ block_label=block_label,
+ prompt_name=prompt_name,
+ dict_key_count=len(parsed),
+ dict_key_preview=log_preview,
+ )
+ return code_str
+ for v in parsed.values():
+ if isinstance(v, str) and v.strip().startswith("async def "):
+ return v.strip()
return None
diff --git a/tests/unit/cli/__init__.py b/tests/unit/cli/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/unit/cli/test_quickstart_compose_env.py b/tests/unit/cli/test_quickstart_compose_env.py
new file mode 100644
index 000000000..0f8ec6987
--- /dev/null
+++ b/tests/unit/cli/test_quickstart_compose_env.py
@@ -0,0 +1,52 @@
+from unittest.mock import patch
+
+from skyvern.cli.quickstart import _COMPOSE_DATABASE_STRING, _bootstrap_compose_env_files
+
+
+def test_bootstrap_compose_env_files_copies_when_missing(tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / ".env.example").write_text("OPENAI_API_KEY=\n")
+ (tmp_path / "skyvern-frontend").mkdir()
+ (tmp_path / "skyvern-frontend" / ".env.example").write_text("VITE_FOO=bar\n")
+
+ _bootstrap_compose_env_files()
+
+ assert (tmp_path / ".env").read_text() == "OPENAI_API_KEY=\n"
+ assert (tmp_path / "skyvern-frontend" / ".env").read_text() == "VITE_FOO=bar\n"
+
+
+def test_bootstrap_compose_env_files_does_not_overwrite_existing(tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / ".env.example").write_text("OPENAI_API_KEY=\n")
+ (tmp_path / ".env").write_text("USER_VALUE=keep\n")
+
+ _bootstrap_compose_env_files()
+
+ assert (tmp_path / ".env").read_text() == "USER_VALUE=keep\n"
+
+
+def test_bootstrap_rewrites_localhost_database_string_when_user_confirms(tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / ".env").write_text(
+ 'OPENAI_API_KEY=sk-dummy\nDATABASE_STRING="postgresql+psycopg://skyvern@localhost/skyvern"\nOTHER=keep\n'
+ )
+
+ with patch("skyvern.cli.quickstart.Confirm.ask", return_value=True):
+ _bootstrap_compose_env_files()
+
+ new_content = (tmp_path / ".env").read_text()
+ assert "localhost" not in new_content
+ assert f'DATABASE_STRING="{_COMPOSE_DATABASE_STRING}"' in new_content
+ assert "OPENAI_API_KEY=sk-dummy" in new_content
+ assert "OTHER=keep" in new_content
+
+
+def test_bootstrap_leaves_database_string_alone_when_user_declines(tmp_path, monkeypatch):
+ monkeypatch.chdir(tmp_path)
+ original = 'OPENAI_API_KEY=sk-dummy\nDATABASE_STRING="postgresql+psycopg://skyvern@localhost/skyvern"\n'
+ (tmp_path / ".env").write_text(original)
+
+ with patch("skyvern.cli.quickstart.Confirm.ask", return_value=False):
+ _bootstrap_compose_env_files()
+
+ assert (tmp_path / ".env").read_text() == original
diff --git a/tests/unit/test_copilot_timeout_wip.py b/tests/unit/test_copilot_timeout_wip.py
index 95d64cf0d..ad8005d4a 100644
--- a/tests/unit/test_copilot_timeout_wip.py
+++ b/tests/unit/test_copilot_timeout_wip.py
@@ -11,12 +11,8 @@ from skyvern.forge.sdk.copilot.agent import (
_TIMEOUT_REPLY_DEFAULT,
_TIMEOUT_REPLY_TESTED,
_TIMEOUT_REPLY_UNVALIDATED,
- _UNEXPECTED_ERROR_REPLY_DEFAULT,
- _UNEXPECTED_ERROR_REPLY_TESTED,
- _UNEXPECTED_ERROR_REPLY_UNVALIDATED,
_build_max_turns_exit_result,
_build_timeout_exit_result,
- _build_unexpected_error_exit_result,
)
@@ -174,64 +170,3 @@ class TestBuildMaxTurnsExitResult:
assert result.updated_workflow is None
assert result.unvalidated is False
assert result.user_response == _MAX_TURNS_REPLY_DEFAULT
-
-
-class TestBuildUnexpectedErrorExitResult:
- def test_no_workflow_falls_back_to_default_reply(self) -> None:
- ctx = _ctx(last_workflow=None, last_workflow_yaml=None, last_test_ok=None)
-
- result = _build_unexpected_error_exit_result(ctx, global_llm_context=None)
-
- assert result.updated_workflow is None
- assert result.workflow_yaml is None
- assert result.unvalidated is False
- assert result.user_response == _UNEXPECTED_ERROR_REPLY_DEFAULT
-
- def test_untested_workflow_surfaces_as_unvalidated_wip(self) -> None:
- wf = MagicMock(name="wf")
- ctx = _ctx(last_workflow=wf, last_workflow_yaml="version: '1.0'", last_test_ok=None)
-
- result = _build_unexpected_error_exit_result(ctx, global_llm_context=None)
-
- assert result.updated_workflow is wf
- assert result.workflow_yaml == "version: '1.0'"
- assert result.unvalidated is True
- assert result.user_response == _UNEXPECTED_ERROR_REPLY_UNVALIDATED
-
- def test_passing_test_surfaces_as_tested_proposal(self) -> None:
- wf = MagicMock(name="wf")
- ctx = _ctx(last_workflow=wf, last_workflow_yaml="version: '1.0'", last_test_ok=True)
-
- result = _build_unexpected_error_exit_result(ctx, global_llm_context=None)
-
- assert result.updated_workflow is wf
- assert result.workflow_yaml == "version: '1.0'"
- assert result.unvalidated is False
- assert result.user_response == _UNEXPECTED_ERROR_REPLY_TESTED
-
- def test_failed_test_drops_proposal(self) -> None:
- wf = MagicMock(name="wf")
- ctx = _ctx(last_workflow=wf, last_workflow_yaml="version: '1.0'", last_test_ok=False)
-
- result = _build_unexpected_error_exit_result(ctx, global_llm_context=None)
-
- assert result.updated_workflow is None
- assert result.workflow_yaml is None
- assert result.unvalidated is False
- assert result.user_response == _UNEXPECTED_ERROR_REPLY_DEFAULT
-
- def test_suspicious_success_drops_proposal(self) -> None:
- wf = MagicMock(name="wf")
- ctx = _ctx(
- last_workflow=wf,
- last_workflow_yaml="version: '1.0'",
- last_test_ok=None,
- last_test_suspicious_success=True,
- )
-
- result = _build_unexpected_error_exit_result(ctx, global_llm_context=None)
-
- assert result.updated_workflow is None
- assert result.workflow_yaml is None
- assert result.unvalidated is False
- assert result.user_response == _UNEXPECTED_ERROR_REPLY_DEFAULT
diff --git a/tests/unit/test_script_reviewer_extract.py b/tests/unit/test_script_reviewer_extract.py
new file mode 100644
index 000000000..9e6bdd027
--- /dev/null
+++ b/tests/unit/test_script_reviewer_extract.py
@@ -0,0 +1,246 @@
+"""Tests for ScriptReviewer._extract_code_from_response and _response_to_text.
+
+Covers SKY-9430: the multi-strategy text-first extractor that bypasses
+parse_api_response by relying on raw_response=True from the LLM handler.
+"""
+
+import json
+
+from structlog.testing import capture_logs
+
+from skyvern.services.script_reviewer import ScriptReviewer
+
+
+class TestResponseToText:
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_string_returned_as_is(self) -> None:
+ assert self.reviewer._response_to_text("foo") == "foo"
+
+ def test_empty_string(self) -> None:
+ assert self.reviewer._response_to_text("") == ""
+
+ def test_choices_dict_extracts_content(self) -> None:
+ response = {"choices": [{"message": {"content": "bar"}}]}
+ assert self.reviewer._response_to_text(response) == "bar"
+
+ def test_legacy_dict_round_trips_through_json(self) -> None:
+ response = {"code": "async def foo(): pass"}
+ text = self.reviewer._response_to_text(response)
+ assert json.loads(text) == response
+
+ def test_dict_without_choices_or_code_round_trips(self) -> None:
+ response = {"foo": "bar"}
+ text = self.reviewer._response_to_text(response)
+ assert json.loads(text) == response
+
+ def test_list_returns_empty(self) -> None:
+ assert self.reviewer._response_to_text([1, 2, 3]) == ""
+
+ def test_none_returns_empty(self) -> None:
+ assert self.reviewer._response_to_text(None) == ""
+
+ def test_choices_with_non_string_content_falls_back_to_dump(self) -> None:
+ response = {"choices": [{"message": {"content": None}}]}
+ text = self.reviewer._response_to_text(response)
+ assert json.loads(text) == response
+
+
+class TestExtractCodeFromResponse:
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_none_returns_none(self) -> None:
+ assert self.reviewer._extract_code_from_response(None) is None
+
+ def test_empty_string_returns_none(self) -> None:
+ assert self.reviewer._extract_code_from_response("") is None
+
+ def test_whitespace_only_returns_none(self) -> None:
+ assert self.reviewer._extract_code_from_response(" \n ") is None
+
+ def test_garbage_text_returns_none(self) -> None:
+ assert self.reviewer._extract_code_from_response("hello world") is None
+
+ def test_cannot_convert_sentinel(self) -> None:
+ assert self.reviewer._extract_code_from_response("CANNOT_CONVERT") == "CANNOT_CONVERT"
+
+ def test_markdown_python_block(self) -> None:
+ text = "```python\nasync def foo(): pass\n```"
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_markdown_python_block_with_prose(self) -> None:
+ text = "Here's the code:\n```python\nasync def foo(): pass\n```"
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_bare_markdown_block(self) -> None:
+ text = "```\nasync def foo(): pass\n```"
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_bare_async_def(self) -> None:
+ text = "async def foo(page, context):\n pass"
+ assert self.reviewer._extract_code_from_response(text) == text
+
+ def test_strict_json_with_code_key(self) -> None:
+ text = '{"code": "async def foo(): pass"}'
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_dict_scan_finds_async_def_in_other_key(self) -> None:
+ text = '{"updated_code": "async def foo(): pass"}'
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_legacy_dict_input_returns_code(self) -> None:
+ response = {"code": "async def foo(): pass"}
+ assert self.reviewer._extract_code_from_response(response) == "async def foo(): pass"
+
+ def test_legacy_choices_dict_with_markdown(self) -> None:
+ response = {"choices": [{"message": {"content": "```python\nasync def foo(): pass\n```"}}]}
+ assert self.reviewer._extract_code_from_response(response) == "async def foo(): pass"
+
+
+class TestModeASignatureSplitRecovery:
+ """SKY-9430 Mode A: LLM emits malformed JSON where unescaped quotes split
+ the function signature across multiple top-level keys after json_repair."""
+
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_signature_split_recovers_compilable_code(self) -> None:
+ text = '{"code": "async def fn(page: T", "context": "U):\\n pass"}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result is not None
+ assert result.startswith("async def fn(page: T, context: U):")
+ compile(result, "<test>", "exec")
+
+ def test_signature_split_via_legacy_dict(self) -> None:
+ response = {
+ "code": "async def fn(page: T",
+ "context": "U):\n pass",
+ }
+ result = self.reviewer._extract_code_from_response(response)
+ assert result is not None
+ compile(result, "<test>", "exec")
+
+ def test_three_split_keys(self) -> None:
+ text = '{"code": "async def fn(page: T", "ctx": "C", "third": "D):\\n pass"}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result is not None
+ compile(result, "<test>", "exec")
+
+
+class TestMonotonicityGuards:
+ """The recovery must never make a currently-passing case start failing."""
+
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_well_formed_with_extra_keys_returns_code_unchanged(self) -> None:
+ text = '{"code": "async def X(): pass", "extra": "noise"}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def X(): pass"
+
+ def test_string_paren_inside_well_formed_code_not_recovered(self) -> None:
+ text = '{"code": "async def X(): print(\\"(\\")", "extra": "noise"}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == 'async def X(): print("(")'
+ compile(result, "<test>", "exec")
+
+ def test_reconstruction_failed_compile_returns_original(self) -> None:
+ text = '{"code": "async def X(", "oops": "))"}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def X("
+
+ def test_non_string_extra_value_bails(self) -> None:
+ text = '{"code": "async def X(", "context": 12345}'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def X("
+
+
+class TestModeBFieldMapNotRecovered:
+ """SKY-9430 Mode B: LLM ignores 'return a function' instruction and emits
+ a FIELD_MAP-shaped JSON. No async def anywhere — extractor returns None.
+ Documented as deferred; needs prompt-side fix."""
+
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_field_map_response_returns_none(self) -> None:
+ text = (
+ '{"class_code": {"param": "class_code", "action": "fill"},'
+ '"agency_program": {"param": null, "action": "fill"}}'
+ )
+ assert self.reviewer._extract_code_from_response(text) is None
+
+
+class TestKwargsOptional:
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_no_kwargs(self) -> None:
+ text = "```python\nasync def foo(): pass\n```"
+ assert self.reviewer._extract_code_from_response(text) == "async def foo(): pass"
+
+ def test_with_kwargs(self) -> None:
+ text = "```python\nasync def foo(): pass\n```"
+ result = self.reviewer._extract_code_from_response(
+ text, block_label="test_block", prompt_name="script-reviewer"
+ )
+ assert result == "async def foo(): pass"
+
+
+class TestRecoveryLogging:
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_recovery_failed_compile_warning_emitted(self) -> None:
+ text = '{"code": "async def X(", "oops": "))"}'
+ with capture_logs() as logs:
+ result = self.reviewer._extract_code_from_response(
+ text, block_label="bad_block", prompt_name="script-reviewer"
+ )
+ assert result == "async def X("
+ failed = [e for e in logs if e.get("event") == "ScriptReviewer: malformed-dict recovery failed compile"]
+ assert len(failed) == 1
+ assert failed[0]["prompt_name"] == "script-reviewer"
+ assert failed[0]["block_label"] == "bad_block"
+
+
+class TestFenceWrappedJson:
+ """SKY-9430 / debate round 2 / CORR-1: when the LLM wraps JSON inside a
+ markdown fence, the extractor must fall through to the JSON parsing branch
+ instead of returning the JSON text as code."""
+
+ def setup_method(self) -> None:
+ self.reviewer = ScriptReviewer()
+
+ def test_well_formed_json_inside_python_fence(self) -> None:
+ text = '```python\n{"code": "async def fn(): pass"}\n```'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def fn(): pass"
+
+ def test_well_formed_json_inside_bare_fence(self) -> None:
+ text = '```\n{"code": "async def fn(): pass"}\n```'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def fn(): pass"
+
+ def test_mode_a_malformed_json_inside_python_fence_recovers(self) -> None:
+ text = '```python\n{"code": "async def fn(page: T", "context": "U):\\n pass"}\n```'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result is not None
+ assert result.startswith("async def fn(page: T, context: U):")
+ compile(result, "<test>", "exec")
+
+ def test_well_formed_json_inside_json_tagged_fence(self) -> None:
+ text = '```json\n{"code": "async def fn(): pass"}\n```'
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def fn(): pass"
+
+ def test_py_tagged_fence_extracts_python(self) -> None:
+ text = "```py\nasync def foo(): pass\n```"
+ result = self.reviewer._extract_code_from_response(text)
+ assert result == "async def foo(): pass"
+
+ def test_fence_with_unsupported_content_returns_none(self) -> None:
+ text = "```python\nsome prose, no JSON, no function\n```"
+ assert self.reviewer._extract_code_from_response(text) is None
diff --git a/tests/unit/test_workflow_copilot_route.py b/tests/unit/test_workflow_copilot_route.py
index 97164d08c..1b2f8e95e 100644
--- a/tests/unit/test_workflow_copilot_route.py
+++ b/tests/unit/test_workflow_copilot_route.py
@@ -24,11 +24,7 @@ import pytest
from skyvern.config import settings
from skyvern.forge import app
from skyvern.forge.sdk.routes.workflow_copilot import COPILOT_V2_FLAG_KEY, workflow_copilot_chat_post
-from skyvern.forge.sdk.schemas.workflow_copilot import (
- WorkflowCopilotChatRequest,
- WorkflowCopilotStreamErrorUpdate,
- WorkflowCopilotStreamResponseUpdate,
-)
+from skyvern.forge.sdk.schemas.workflow_copilot import WorkflowCopilotChatRequest, WorkflowCopilotStreamResponseUpdate
def _make_chat_request() -> WorkflowCopilotChatRequest:
@@ -448,7 +444,6 @@ async def test_unvalidated_timeout_wip_overrides_auto_accept(monkeypatch: pytest
)
assert response_frame is not None
assert getattr(response_frame, "unvalidated", False) is True
- assert not [f for f in sent_frames if isinstance(f, WorkflowCopilotStreamErrorUpdate)]
@pytest.mark.asyncio
diff --git a/uv.lock b/uv.lock
index 9a37828cf..4623ff628 100644
--- a/uv.lock
+++ b/uv.lock
@@ -5564,7 +5564,7 @@ wheels = [
[[package]]
name = "skyvern"
-version = "1.0.31"
+version = "1.0.32"
source = { editable = "." }
dependencies = [
{ name = "aioboto3" },