Skip to main content
Read the Notte skill and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
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
Then schedule the function by its ID, as described in Function Schedules.

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:
monitor-function-success.py

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