Portal Community

The Problem AI Functions Solve

Custom tool logic written in C# requires compilation, testing, and deployment — typically a development sprint. For simple transformations, calculations, or formatting operations, this is overhead without value. AI Functions address this by:

The Lifecycle of an AI Function Call

1
Function Requested Either: LLM calls it as an MCP tool, or a Flow Studio node references it by name.
2
Function Loaded from SQL AIFunctionStore retrieves the active function code by name and tenant. Cached in memory for the request lifetime.
3
Sandbox Initialised AIFunctionRuntime creates a new Jint (or V8) engine instance. Global APIs are injected (see Sandbox page).
4
Function Executed Input data passed as a JavaScript object; execute(input) called; return value captured.
5
Output Returned Return value serialised as JSON and returned to the caller (LLM tool result or workflow node output).

Key Properties

PropertyValue
LanguageJavaScript (ES2020 subset via Jint; or full Node.js via V8 isolate)
StorageSQL Server (Octopus_AIFunctions)
Entry pointMust export/define an execute(input) function
Return valueAny JSON-serialisable value (object, array, string, number, boolean)
IsolationNew sandbox instance per call — no shared state between calls
TimeoutConfigurable max execution time (default 5 seconds)
Memory limitConfigurable heap limit per execution (default 64 MB)

Good Use Cases

Use CaseExample
Data formattingFormat a currency amount for the user's locale
CalculationsCalculate leave days remaining given dates and entitlement
Data transformationConvert a raw API response into a clean structured summary
Simple validationValidate an email address or phone number format
Text processingExtract key facts from a template-formatted text block
Not a Replacement for Full Tools

AI Functions cannot make HTTP calls, access the filesystem, or call databases directly (unless services are injected via the sandbox API). For database queries, external API calls, or authentication-gated operations, use a Custom C# Tool Plugin instead.