Skip to content

Automate browser based workflows with AI

Remove successful action history. Only show the failure of the previous step in action history. (#602)

Kerem Yilmazcdd731b862d7
diff --git a/skyvern/config.py b/skyvern/config.py
index ac7c79912..06014e6bb 100644
--- a/skyvern/config.py
+++ b/skyvern/config.py
@@ -23,7 +23,7 @@ class Settings(BaseSettings):
MAX_RETRIES_PER_STEP: int = 5
DEBUG_MODE: bool = False
DATABASE_STRING: str = "postgresql+psycopg://skyvern@localhost/skyvern"
- PROMPT_ACTION_HISTORY_WINDOW: int = 5
+ PROMPT_ACTION_HISTORY_WINDOW: int = 1
TASK_RESPONSE_ACTION_SCREENSHOT_COUNT: int = 3
ENV: str = "local"
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index e1b4fa0b6..ffcc7a36d 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -1017,13 +1017,14 @@ class ForgeAgent:
async def _get_action_results(self, task: Task) -> str:
# Get action results from the last app.SETTINGS.PROMPT_ACTION_HISTORY_WINDOW steps
steps = await app.DATABASE.get_task_steps(task_id=task.task_id, organization_id=task.organization_id)
- window_steps = steps[-1 * SettingsManager.get_settings().PROMPT_ACTION_HISTORY_WINDOW :]
+ # the last step is always the newly created one and it should be excluded from the history window
+ window_steps = steps[-1 - SettingsManager.get_settings().PROMPT_ACTION_HISTORY_WINDOW : -1]
actions_and_results: list[tuple[Action, list[ActionResult]]] = []
for window_step in window_steps:
if window_step.output and window_step.output.actions_and_results:
actions_and_results.extend(window_step.output.actions_and_results)
- # shall we exclude successful actions?
+ # exclude successful action from history
return json.dumps(
[
{
@@ -1044,6 +1045,7 @@ class ForgeAgent:
],
}
for action, results in actions_and_results
+ if len(results) > 0 and not results[-1].success
]
)