Skip to main content

Overview

Agent Fallback are mechanisms that allow you to gracefully handle script execution failures without any additional code:
agent_fallback.py
from notte_sdk import NotteClient

client = NotteClient()
url = "https://www.linkedin.com/feed/"
company_name = "nottelabs"

# scrape all new posts (post url, date, title, content) from the company page on LinkedIn
with client.Session() as session:
    session.execute(type="goto", url=url)
    # spin up agent fallback if the search for the company name fails
    with client.AgentFallback(
        session=session, task=f"Open the company page for {company_name}. Fail if user is not logged in."
    ) as agent:
        # search for the company name
        session.execute(type="fill", selector='internal:role=combobox[name="Search"i]', value=company_name)
        # press enter to search
        session.execute(type="press_key", key="Enter")
        # click on the company link
        session.execute(type="click", selector=f'internal:role=link[name="{company_name}"s] >> nth=0')
    # open the post tab on the company page
    session.execute(type="click", selector='internal:role=link[name="Posts"i]', raise_on_failure=False)
    data = session.scrape(instructions="scrape all new posts (post url, date, title, content)")
    print(f"Scraped data: {data}")
They ensure your scripts always terminate successfully even if the website changes or something unexpected happens.

Parameters

session
RemoteSession
required
task
str
required
reasoning_model
notte_core.common.config.LlmModel | str
The language model to use for agent reasoning.
use_vision
bool
Whether to enable vision capabilities for the agent.
max_steps
int
Maximum number of steps the agent can take.
vault_id
str | None
Optional ID of the vault to use.
persona_id
str | None
notifier_config
dict[str, typing.Any] | None
Config used for the notifier.