append complete action (for validation) to the end of every task block (#3726)

This commit is contained in:
Shuchang Zheng
2025-10-15 17:12:51 -07:00
committed by GitHub
parent c78b80ab89
commit cfaef5a8bb
6 changed files with 92 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
import uuid
from contextlib import asynccontextmanager
from datetime import datetime
from typing import Any, AsyncGenerator, Awaitable, Callable
from typing import Awaitable, Callable
import structlog
from fastapi import FastAPI, Response, status
@@ -51,20 +50,12 @@ def custom_openapi() -> dict:
return app.openapi_schema
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncGenerator[None, Any]:
"""Lifespan context manager for FastAPI app startup and shutdown."""
LOG.info("Server started")
yield
LOG.info("Server shutting down")
def get_agent_app() -> FastAPI:
"""
Start the agent server.
"""
app = FastAPI(lifespan=lifespan)
app = FastAPI()
# Add CORS middleware
app.add_middleware(

View File

@@ -23,6 +23,7 @@ from skyvern.exceptions import (
FailedToSendWebhook,
InvalidCredentialId,
MissingValueForParameter,
ScriptTerminationException,
SkyvernException,
WorkflowNotFound,
WorkflowRunNotFound,
@@ -678,9 +679,17 @@ class WorkflowService:
LOG.debug("Executing run_signature wrapper", wrapper_code=wrapper_code)
exec_code = compile(wrapper_code, "<run_signature>", "exec")
exec(exec_code, exec_globals)
output_value = await exec_globals["__run_signature_wrapper"]()
try:
exec_code = compile(wrapper_code, "<run_signature>", "exec")
exec(exec_code, exec_globals)
output_value = await exec_globals["__run_signature_wrapper"]()
except ScriptTerminationException as e:
LOG.warning(
"Script termination",
block_label=block.label,
error=str(e),
exc_info=True,
)
# Execution succeeded - get the block result from the workflow run blocks
# The script execution should have created the workflow run block