Nodes/ComfyUI Griptape Nodes/Griptape Code: Run Python [DEPRECATED]
ComfyUI Node

Griptape Code: Run Python [DEPRECATED]

Run Python inside a task — deprecated, but still here with a guardrail

By griptape-ai·Created 2 years ago·Updated about a year ago· 238
Griptape Code: Run Python [DEPRECATED]
  • agent
  • OUTPUT
  • AGENT
inputThis text will be passed as `input` to the code.
examplesCustom code
code# Python code to execute. # `input` is any input text. # `output` will be returned as the task output output = input.upper()

The one-liner: this node executes Python code you paste in, takes an input string, and returns whatever you assign to an output variable. It's marked DEPRECATED because running arbitrary code inside ComfyUI is exactly the kind of thing that gets people's machines compromised - and this pack has a known security history to be careful about. It still exists and it still works, but the pack's own changelog says to use "Griptape Code: Run Griptape Cloud Structure" instead.

How it works

The node wraps your code as a CodeExecutionTask inside an agent. The code block gets input (the value of the required input STRING) and whatever you define as output is returned. There are a few preset snippets in the examples dropdown (word count, reverse, sort, extract numbers, etc.) to get you started. Outputs are OUTPUT (STRING) and AGENT.

Here's the part worth understanding, because it's changed since the node was deprecated: the current source actually runs your script through an AST-based allowlist checker before executing. It parses the code, walks the imports, and blocks anything not on an approved list (standard library modules, plus things like numpy, pandas, PIL, json, re - and it specifically flags exec and __import__ calls). Code that fails the check is refused. So the "Run Python" node isn't an open sandbox anymore - but it's also not a real sandbox, and the deprecation stands for a reason.

The inputs that matter

  • input (required) - the text passed to your code as input.
  • code - your Python, which should define output.
  • examples - preset snippets to drop in.
  • agent - an agent to run the task through (one is created if absent).

Installing it

It ships in the one pack:

cd ComfyUI/custom_nodes
git clone https://github.com/griptape-ai/ComfyUI-Griptape

or ComfyUI Manager → search "Griptape". Restart, and it's under the Griptape menu → Code. No API key needed for the node itself - it's local execution.

The security situation - read this

The ComfyUI ecosystem has a documented history here: custom nodes run arbitrary Python on import, and a malicious node in this space already led to compromised machines and a federal prosecution (the ComfyUI_LLMVISION incident, well documented across the community). Running your own code through this node is a much smaller risk than installing unknown nodes, but the allowlist is a guardrail, not a guarantee - it blocks dodgy imports, not clever attacks. The pack deprecated this node explicitly "due to security concerns over the exec command." The practical advice: for anything you want to run regularly or share, prefer the Cloud Structure node so the code executes on Griptape's infra instead of your machine. For quick one-off text munging where you trust your own code, this still works fine.

Common issues

  • "Unapproved import" rejection - your code imports something off the list (e.g. os in a non-os.path form, subprocess, requests). Refactor or accept you can't use it here.
  • output undefined - the task expects an output variable; forgetting it errors at runtime.
  • Empty output - returning None gives you nothing back on the OUTPUT socket.
  • Deprecation warning fatigue - yes, it's deprecated and will eventually be removed. Plan the Cloud Structure migration for anything you rely on.
CategoryGriptape/Code

Inputs (4)

NameTypeDefaultDescription
inputSTRINGThis text will be passed as `input` to the code.
agentoptAGENT
examplesoptCOMBOCustom codeSelect an example code snippet to replace the default code.
codeoptSTRING# Python code to execute. # `input` is any input text. # `output` will be returned as the task output output = input.upper() Python code to execute. The code should define an `output` variable that will be returned as the task's output. Example: # Sorts a list of numbers def sort_numbers(numbers): return sorted(numbers) output = str(sort_numbers([int(x) for x in input.split(',')]))

Outputs (2)

NameTypeDescription
OUTPUTSTRING
AGENTAGENT