AI agent instructions
AI agent instructions
Mark a failure as expected or retryable
Raise an exception that subclassesExpectedFunctionError for a deliberate refusal, or RetryableFunctionError for a temporary problem:
typed_errors.py
notte_sdk.errors, but not every Function runtime includes that SDK version yet, and a Function that imports a name its runtime doesn’t have fails on every run.
Mix them with a built-in exception, as AccountNotUnique(ValueError, ExpectedFunctionError) does, so except ValueError still catches it when you run the code locally.
retry tells the caller that running the Function again may succeed. Notte never re-runs it for you, because a run can already have had side effects, such as a submitted form.
You can override heal, retry, status_code or code as class attributes, as status_code = 409 does above. code defaults to the class name in snake_case (account_not_unique). The run itself still answers with HTTP 200, so status_code is informational.
Mark existing exceptions as expected without changing code
List exception class names in the Function’sexpected_errors. A failed run whose exception has one of these names anywhere in its class hierarchy ends as rejected and is not self-healed, exactly as if it subclassed ExpectedFunctionError:
Set function_id (Python) or functionId (TypeScript) to your Function’s ID.
PATCH /functions/{function_id} with {"expected_errors": ["AccountNotUnique"]}. The list holds up to 50 Python class names. It belongs to the Function, so it applies to every run, whoever starts it.
Read a rejected run
The run’serror field describes the exception:
In the Python SDK,
function.run() raises FunctionRunRejectedError for a rejected run, with the payload in its error attribute and the code in code. It subclasses FailedToRunCloudFunctionError, so handlers you already have still catch it. The TypeScript SDK throws FunctionRunRejectedError too, or returns the run when you pass raiseOnFailure: false.
rejected is a newer run status. SDK releases before it are shown a rejected run as failed, which they already handle. The Python SDK from 1.10.12 and the TypeScript SDK from 1.10.13 ask for rejected with the x-notte-accept-run-statuses: rejected header. Other HTTP clients always see rejected.
Next Steps
Creating Functions
Write and deploy Functions
Management
Update metadata and monitor runs