Skip to main content
code nodes run a small inline transform against the run context. Used when the logic is too compact to merit a vendor call but too compositional for rules.

Configuration

{
  "id": "cd-aggregate",
  "type": "code",
  "data": {
    "label": "Aggregate AML Results",
    "language": "python",
    "code": "high_risk = sum(1 for r in beneficiary_results if r and r.sanctions_check and r.sanctions_check.match_score >= 80)\nreturn { 'high_risk_count': high_risk, 'total_screened': len(beneficiary_results or []) }",
    "outputVariable": "aml_aggregate",
    "timeout": 2000,
  },
}
FieldNotes
languagepython in production. Sandbox-restricted.
codeThe transform. Run context is bound in scope (no input prefix needed in code; just data, the variable names, etc).
outputVariableWhere the return value lands.
timeoutMilliseconds. Defaults small (2s) because code is local.

Sandboxing

The Python sandbox restricts:
  • No filesystem access.
  • No network calls (use customApi for that).
  • No imports beyond a whitelist: math, statistics, json, re, datetime, decimal.
  • CPU and memory limits enforced.

When to use code

Aggregation across array variables (sum, len, any, all, max_by).
Reshape arrays into a different schema before passing to AI synthesis.
Compute a derived field that’s too small for a vendor call (e.g. distance between two coordinates).

When NOT to use code

If the transform is a single comparison or boolean — use rule or condition instead. Code nodes are harder to reason about in a regulator walk-through.
If the transform calls an external service — use customApi. Code nodes can’t reach the network.