> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notte.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Fallback

> Gracefully handle script execution failures with Web Agents

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

# Overview

Agent Fallback are mechanisms that allow you to gracefully handle script execution failures without any additional code:

{/* @sniptest testers/agents/fallback.py */}

```python agent_fallback.py highlight={11-18} theme={null}
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

<ParamField path="session" type="RemoteSession" required />

<ParamField path="task" type="str" required />

<ParamField path="response_format" type="UnionType[type[BaseModel], None]" default="None" />

<ParamField path="reasoning_model" type="notte_core.common.config.LlmModel | str">
  The language model to use for agent reasoning.
</ParamField>

<ParamField path="use_vision" type="bool">
  Whether to enable vision capabilities for the agent.
</ParamField>

<ParamField path="max_steps" type="int">
  Maximum number of steps the agent can take.
</ParamField>

<ParamField path="vault_id" type="str | None">
  Optional ID of the vault to use.
</ParamField>

<ParamField path="persona_id" type="str | None" />

<ParamField path="notifier_config" type="dict[str, typing.Any] | None">
  Config used for the notifier.
</ParamField>
