Post action improvements: only generate scripts for a certain list of actions (#3676)

This commit is contained in:
Shuchang Zheng
2025-10-15 12:41:52 -07:00
committed by GitHub
parent dfe8d6fb85
commit 6b385b3c85
3 changed files with 21 additions and 6 deletions

View File

@@ -1229,7 +1229,7 @@ class ForgeAgent:
}
results = await ActionHandler.handle_action(scraped_page, task, step, current_page, action)
await app.AGENT_FUNCTION.post_action_execution()
await app.AGENT_FUNCTION.post_action_execution(action)
detailed_agent_step_output.actions_and_results[action_idx] = (
action,
results,
@@ -1404,7 +1404,6 @@ class ForgeAgent:
complete_results = await ActionHandler.handle_action(
scraped_page, task, step, working_page, complete_action
)
await app.AGENT_FUNCTION.post_action_execution()
detailed_agent_step_output.actions_and_results.append((complete_action, complete_results))
await self.record_artifacts_after_action(task, step, browser_state, engine)
@@ -1424,7 +1423,7 @@ class ForgeAgent:
extract_results = await ActionHandler.handle_action(
scraped_page, task, step, working_page, extract_action
)
await app.AGENT_FUNCTION.post_action_execution()
await app.AGENT_FUNCTION.post_action_execution(extract_action)
detailed_agent_step_output.actions_and_results.append((extract_action, extract_results))
# If no action errors return the agent state and output

View File

@@ -21,6 +21,8 @@ from skyvern.forge.sdk.schemas.tasks import Task, TaskStatus
from skyvern.forge.sdk.trace import TraceManager
from skyvern.forge.sdk.workflow.models.block import BlockTypeVar
from skyvern.services import workflow_script_service
from skyvern.webeye.actions.action_types import POST_ACTION_EXECUTION_ACTION_TYPES
from skyvern.webeye.actions.actions import Action
from skyvern.webeye.browser_factory import BrowserState
from skyvern.webeye.scraper.scraper import ELEMENT_NODE_ATTRIBUTES, CleanupElementTreeFunc, json_to_html
from skyvern.webeye.utils.dom import SkyvernElement
@@ -617,10 +619,12 @@ class AgentFunction:
if not settings.ENABLE_CODE_BLOCK:
raise DisabledBlockExecutionError("CodeBlock is disabled")
async def _post_action_execution(self) -> None:
async def _post_action_execution(self, action: Action) -> None:
"""
If this is a workflow running environment, generate the
"""
if action.action_type not in POST_ACTION_EXECUTION_ACTION_TYPES:
return
context = skyvern_context.current()
if (
not context
@@ -652,5 +656,5 @@ class AgentFunction:
workflow=workflow,
)
async def post_action_execution(self) -> None:
asyncio.create_task(self._post_action_execution())
async def post_action_execution(self, action: Action) -> None:
asyncio.create_task(self._post_action_execution(action))

View File

@@ -37,3 +37,15 @@ class ActionType(StrEnum):
ActionType.SELECT_OPTION,
ActionType.CHECKBOX,
]
POST_ACTION_EXECUTION_ACTION_TYPES = [
ActionType.CLICK,
ActionType.INPUT_TEXT,
ActionType.UPLOAD_FILE,
ActionType.DOWNLOAD_FILE,
ActionType.SELECT_OPTION,
ActionType.WAIT,
ActionType.SOLVE_CAPTCHA,
ActionType.EXTRACT,
]