code block validation (#2017)

This commit is contained in:
Shuchang Zheng 2025-03-25 02:47:02 -07:00 committed by GitHub
parent 915bcfbf13
commit 54dadcf370
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -9,7 +9,7 @@ from playwright.async_api import Frame, Page
from skyvern.config import settings from skyvern.config import settings
from skyvern.constants import SKYVERN_ID_ATTR from skyvern.constants import SKYVERN_ID_ATTR
from skyvern.exceptions import StepUnableToExecuteError, TaskAlreadyTimeout from skyvern.exceptions import DisabledBlockExecutionError, StepUnableToExecuteError, TaskAlreadyTimeout
from skyvern.forge import app from skyvern.forge import app
from skyvern.forge.async_operations import AsyncOperation from skyvern.forge.async_operations import AsyncOperation
from skyvern.forge.prompts import prompt_engine from skyvern.forge.prompts import prompt_engine
@ -503,3 +503,7 @@ class AgentFunction:
return element_tree return element_tree
return cleanup_element_tree_func return cleanup_element_tree_func
async def validate_code_block(self, organization_id: str | None = None) -> None:
if not settings.ENABLE_CODE_BLOCK:
raise DisabledBlockExecutionError("CodeBlock is disabled")

View file

@ -30,7 +30,6 @@ from skyvern.config import settings
from skyvern.constants import GET_DOWNLOADED_FILES_TIMEOUT, MAX_UPLOAD_FILE_COUNT from skyvern.constants import GET_DOWNLOADED_FILES_TIMEOUT, MAX_UPLOAD_FILE_COUNT
from skyvern.exceptions import ( from skyvern.exceptions import (
ContextParameterValueNotFound, ContextParameterValueNotFound,
DisabledBlockExecutionError,
MissingBrowserState, MissingBrowserState,
MissingBrowserStatePage, MissingBrowserStatePage,
SkyvernException, SkyvernException,
@ -1192,8 +1191,7 @@ async def wrapper():
browser_session_id: str | None = None, browser_session_id: str | None = None,
**kwargs: dict, **kwargs: dict,
) -> BlockResult: ) -> BlockResult:
if not settings.ENABLE_CODE_BLOCK: await app.AGENT_FUNCTION.validate_code_block(organization_id=organization_id)
raise DisabledBlockExecutionError("CodeBlock is disabled")
# TODO: only support to use code block to manupilate the browser page # TODO: only support to use code block to manupilate the browser page
# support browser context in the future # support browser context in the future