From cdd731b862d7bf5aaa3035dc01c3884f515af1aa Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Fri, 12 Jul 2024 08:57:50 -0700 Subject: [PATCH] Remove successful action history. Only show the failure of the previous step in action history. (#602) --- skyvern/config.py | 2 +- skyvern/forge/agent.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/skyvern/config.py b/skyvern/config.py index ac7c7991..06014e6b 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 e1b4fa0b..ffcc7a36 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 ] )