add workflow_run.script_run and mark ai_fallback_triggered when the script falls back to ai run (#3433)

This commit is contained in:
Shuchang Zheng
2025-09-14 22:53:52 -07:00
committed by GitHub
parent 975376698d
commit 720ebac72c
9 changed files with 74 additions and 2 deletions

View File

@@ -1672,6 +1672,7 @@ class AgentDB:
status: WorkflowRunStatus | None = None,
failure_reason: str | None = None,
webhook_failure_reason: str | None = None,
ai_fallback_triggered: bool | None = None,
) -> WorkflowRun:
async with self.Session() as session:
workflow_run = (
@@ -1690,6 +1691,8 @@ class AgentDB:
workflow_run.failure_reason = failure_reason
if webhook_failure_reason is not None:
workflow_run.webhook_failure_reason = webhook_failure_reason
if ai_fallback_triggered is not None:
workflow_run.script_run = {"ai_fallback_triggered": ai_fallback_triggered}
await session.commit()
await session.refresh(workflow_run)
await save_workflow_run_logs(workflow_run_id)
@@ -2936,6 +2939,7 @@ class AgentDB:
http_request_parameters: dict[str, Any] | None = None,
http_request_timeout: int | None = None,
http_request_follow_redirects: bool | None = None,
ai_fallback_triggered: bool | None = None,
) -> WorkflowRunBlock:
async with self.Session() as session:
workflow_run_block = (
@@ -2993,6 +2997,8 @@ class AgentDB:
workflow_run_block.http_request_timeout = http_request_timeout
if http_request_follow_redirects is not None:
workflow_run_block.http_request_follow_redirects = http_request_follow_redirects
if ai_fallback_triggered is not None:
workflow_run_block.script_run = {"ai_fallback_triggered": ai_fallback_triggered}
await session.commit()
await session.refresh(workflow_run_block)
else:

View File

@@ -283,6 +283,7 @@ class WorkflowRunModel(Base):
max_screenshot_scrolling_times = Column(Integer, nullable=True)
extra_http_headers = Column(JSON, nullable=True)
browser_address = Column(String, nullable=True)
script_run = Column(JSON, nullable=True)
queued_at = Column(DateTime, nullable=True)
started_at = Column(DateTime, nullable=True)

View File

@@ -50,7 +50,7 @@ from skyvern.forge.sdk.workflow.models.workflow import (
WorkflowRunStatus,
WorkflowStatus,
)
from skyvern.schemas.runs import ProxyLocation
from skyvern.schemas.runs import ProxyLocation, ScriptRunResponse
from skyvern.schemas.scripts import Script, ScriptBlock, ScriptFile
from skyvern.schemas.workflows import BlockStatus, BlockType
from skyvern.webeye.actions.actions import (
@@ -303,6 +303,7 @@ def convert_to_workflow_run(
max_screenshot_scrolls=workflow_run_model.max_screenshot_scrolling_times,
extra_http_headers=workflow_run_model.extra_http_headers,
browser_address=workflow_run_model.browser_address,
script_run=ScriptRunResponse.model_validate(workflow_run_model.script_run),
)