What “writing a function” means
A worker contributes capability by registering functions. Each function has anid of the form
service::name, a handler that receives the payload and returns a result, and optional JSON
Schemas that describe the request and response shape.
For how callers invoke functions (worker.trigger / iii trigger / event-bound triggers), see
Using iii / Functions and
Using iii / Triggers. This page is about the authoring surface.
Register a function
Inside the worker, register the function with the SDK. Theid is what callers pass as
function_id; the handler signature is the same regardless of how the invocation arrived (direct
call, HTTP trigger, cron, queue message).
- Node / TypeScript
- Python
- Rust
Attach request and response schemas
Attach JSON Schemas to the registration so the request and response shape are documented alongside the function. The schemas are stored with the function and surface in the iii console and the agent-readable skills.Runtime validation is not yet supported. Attached schemas are metadata only; the engine does not
reject payloads or handler return values that don’t match them.
- Node / TypeScript
- Python
- Rust
Return values and errors
A function returns either a value (which the handler is responsible for shaping to match its documented response schema) or an error. Errors raised inside the handler are propagated to the caller as invocation errors with the worker’s stack trace; the engine doesn’t swallow them. Use this distinction to express expected failures (return a structured error value) versus unexpected ones (throw / raise / returnErr).
Unregister a function
registerFunction returns a handle with an unregister() method that removes the function from
the engine at runtime. When the worker disconnects, all of its functions are removed automatically
and pending invocations error out.
- Node / TypeScript
- Python
- Rust