Skip to content

Commit

Permalink
cancel stop loading window
Browse files Browse the repository at this point in the history
  • Loading branch information
LawyZheng committed Jul 1, 2024
1 parent eb7478a commit 4c22bdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion skyvern/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class ScrapeType(StrEnum):
RELOAD = "reload"


SCRAPE_TYPE_ORDER = [ScrapeType.NORMAL, ScrapeType.STOPLOADING, ScrapeType.RELOAD]
SCRAPE_TYPE_ORDER = [ScrapeType.NORMAL, ScrapeType.NORMAL, ScrapeType.RELOAD]
20 changes: 10 additions & 10 deletions skyvern/forge/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,24 +876,24 @@ async def _build_and_record_step_prompt(
# Scrape the web page and get the screenshot and the elements
# HACK: try scrape_website three time to handle screenshot timeout
# first time: normal scrape to take screenshot
# second time: stop window loading before scraping
# second time: try again the normal scrape, (stopping window loading before scraping barely helps, but causing problem)
# third time: reload the page before scraping
scraped_page: ScrapedPage | None = None
for scrape_type in SCRAPE_TYPE_ORDER:
for idx, scrape_type in enumerate(SCRAPE_TYPE_ORDER):
try:
scraped_page = await self._scrape_with_type(
task=task, step=step, browser_state=browser_state, scrape_type=scrape_type
)
break
except FailedToTakeScreenshot as e:
if scrape_type == ScrapeType.RELOAD:
LOG.error(
"Failed to take screenshot after stop-loading and reload-page retry",
task_id=task.task_id,
step_id=step.step_id,
)
raise e
continue
if idx < len(SCRAPE_TYPE_ORDER) - 1:
continue
LOG.error(
"Failed to take screenshot after two normal attemps and reload-page retry",
task_id=task.task_id,
step_id=step.step_id,
)
raise e

if scraped_page is None:
raise EmptyScrapePage
Expand Down

0 comments on commit 4c22bdb

Please sign in to comment.