Skip to main content
STOP. Do not read past this section until you have read and followed /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.
Convert successful agent runs into deterministic function code that can be executed faster and cheaper than agents.

Overview

After an agent completes a task, you can extract the steps as function code:

Why Convert to Functions?

Use functions when:
  • The task is well-defined and repeatable
  • Page structure is stable
  • Speed and cost matter
  • You need predictable execution

Getting Function Code

As Python Script

Get executable Python code:
get-python-script.py
Example output:

As Function Object

Create a reusable function:
create-function-object.py

Running Functions

Execute Generated Code

Review the generated Python before running it:
Generated workflows contain LLM-produced code and should be treated as untrusted. Inspect the entire file, then run it only in an isolated environment with the minimum required permissions.
Before testing the saved file:
  1. Use a disposable container or virtual machine with no host or home-directory mounts.
  2. Provide only short-lived, minimum-scope credentials; generated code can read and transmit every value you expose.
  3. Restrict network access to the destinations the workflow requires, when possible.
  4. Destroy the environment and revoke its credentials after the test.

Use Function API

Run via the function endpoint:
use-function-api.py

Use Cases

1. Prototyping with Agents

Use agents to figure out the automation, then convert:
prototyping-with-agents.py

2. Scheduled Tasks

Convert one-time agent runs to scheduled functions:
scheduled-tasks.py

3. Cost Optimization

Run agents once, then use cheaper functions:
cost-optimization.py

4. Testing Variations

Create function templates from agents:
testing-variations.py

Customizing Generated Code

Add Parameters

Make functions reusable with parameters:
add-parameters.py

Add Error Handling

Enhance with production-ready error handling:
add-error-handling.py

Optimize Selectors

Review and improve generated selectors:
optimize-selectors.py

Best Practices

1. Test Generated Functions

Always test before production:
test-generated-functions.py

2. Document the Source

Track which agent generated the function:
document-the-source.py

3. Version Control

Store functions in git:
version-control.py

4. Monitor Function Success

Track if functions continue to work:

5. Regenerate When Pages Change

When functions break, use agents to update:
regenerate-when-pages-change.py

Limitations

Functions work best for:
  • ✅ Stable, unchanging pages
  • ✅ Deterministic tasks
  • ✅ Known sequences of actions
Functions are not suitable for:
  • ❌ Pages that change frequently
  • ❌ Tasks requiring adaptation
  • ❌ Complex decision-making
When pages change or tasks become complex, revert to agents.

Next Steps

Functions

Deploy automations as serverless APIs

Actions

Available session actions

Agent Configuration

Optimize agent runs

Functions

Deploy and manage serverless functions