Skip to main content

Configure code-executor resource limits

Organization admins can configure the memory available to workflow code blocks during execution. You can set an org-wide default that all workflow runs inherit, and optionally allow workflow editors to override it per workflow.

Configuring limits lets you:

  • Prevent runaway code blocks from consuming all available host resources.
  • Set tighter budgets for organizations running many concurrent workflows.
  • Let teams self-serve a fix for out-of-memory errors without an infrastructure change.

Prerequisites

  • A self-hosted instance on a Business or Enterprise plan
  • The WORKFLOW_MONITOR_PROCESS_ENABLED environment variable set to true on your code-executor container. Without this, resource limits are not enforced regardless of what is configured here.
  • A Retool API access token with:
    • organization:write scope to configure organization-level settings
    • workflows:write scope to configure per-workflow overrides

Default limits

When WORKFLOW_MONITOR_PROCESS_ENABLED is true, the code-executor enforces limits from the WORKFLOW_MEMORY_LIMIT_MBS environment variable on the code-executor container. If that variable is not set, the default is 2,500 MB.

Organization-level and workflow-level limits take priority over these environment variable defaults. If neither is set, the environment variable value applies.

Set organization-level defaults

Organization-level limits apply as defaults across all workflow code blocks in your organization. Use the PUT /api/v2/organization/code-executor-settings endpoint to configure them.

curl -X PUT https://{your-domain}/api/v2/organization/code-executor-settings \
-H 'Authorization: Bearer $RETOOL_API_TOKEN' \
-H 'Content-Type: application/json' \
--data '{
"memoryLimitMbs": 1024,
"maxConcurrentProcesses": 10,
"circuitBreakerEnabled": true
}'

memoryLimitMbs must be between 256 and 32768 (in MB).

Refer to the Retool API reference for all available fields and options.

To read the current organization settings, use GET /api/v2/organization/code-executor-settings:

curl https://{your-domain}/api/v2/organization/code-executor-settings \
-H 'Authorization: Bearer $RETOOL_API_TOKEN'

You can also configure organization-level limits in Settings, under the Advanced section, by clicking Advanced settings.

Override limits per workflow

Workflow editors can override the organization-level default for a specific workflow using PATCH /api/v2/workflows/{workflowId} (requires workflows:write scope), or in the workflow editor under Settings > Resource limits.

Refer to the Retool API reference for all available fields and options.

Limit resolution order

When a code block runs, Retool resolves the effective limit using this priority chain:

  1. Workflow-level override — if a workflow editor has set a limit on that specific workflow, it takes effect.
  2. Organization-level default — if no workflow-level override is set, the organization default applies.
  3. Environment variable default — if neither is configured, the code-executor container's environment variables determine the limit.

When a code block exceeds its limit

If a code block exceeds the enforced memory limit, Retool terminates the process immediately and the block returns the following error:

The process was aborted because memory or cpu limits were breached.

The block fails fast rather than consuming all available host resources. No other blocks in the workflow are affected unless the failed block is a dependency.

Reset a limit to default

Set a field to null to remove an override and fall back to the next priority level.

To remove a per-workflow override (falls back to the organization-level default):

curl -X PATCH https://{your-domain}/api/v2/workflows/{workflowId} \
-H 'Authorization: Bearer $RETOOL_API_TOKEN' \
-H 'Content-Type: application/json' \
--data '{
"code_executor_memory_limit_mbs": null
}'

To remove an organization-level default (falls back to the environment variable):

curl -X PUT https://{your-domain}/api/v2/organization/code-executor-settings \
-H 'Authorization: Bearer $RETOOL_API_TOKEN' \
-H 'Content-Type: application/json' \
--data '{
"memoryLimitMbs": null,
"maxConcurrentProcesses": null
}'