Nodes/LLM Node for ComfyUI/Code Config Node
ComfyUI Node

Code Config Node

The pack's code-execution mode

By Big-Idea-Technology·Created 2 years ago·Updated about a year ago· 71
Code Config Node
    • CodingConfig
    execute_codefalse
    project_folder/projects/LLM

    Most LLM nodes just generate text. This one is different: the Code Config Node flips a switch that makes the main LLM_Node not only write Python files, but run them, read the errors, and feed them back to the model to fix - in a loop. It's easily the most interesting thing in this pack, and also the most dangerous, and you should know both halves before you touch it.

    What it is

    It's a config node with two inputs and one output:

    • execute_code - the master switch. Off by default.
    • project_folder - where finished scripts get copied. Defaults to /projects/LLM.

    Wire the CodingConfig output into the CodingConfig input on the main LLM_Node. With execute_code off, nothing happens - it's the pack's default text generation. Turn it on and the behavior changes completely.

    The mechanism

    Reading the pack's source, once generation is done the main node regex-scrapes python code blocks out of the model's response - honoring filename headers like **main.py:** - and writes each to a tmp folder inside the pack. Then it runs every file with a subprocess under a one-second timeout with SDL_VIDEODRIVER=dummy so nothing pops a window. A file that errors triggers the "fixme" loop: the traceback is appended to the prompt, the model is told "Fix the code. Write all code. Don't take shortcut", and it regenerates and retries - up to 10 attempts. Once files pass, they're copied into project_folder and main.py is executed for real.

    So the intended use is self-healing codegen: ask the model to write a small script, and let the loop converge on something that runs. It's a niche, fiddly feature - the one-second timeout means any script that actually does real work will "time out" and trip the fix loop, so it's really built for tiny self-contained snippets.

    The warning

    This node executes model-generated Python with your user account, no sandbox, no approval step. A malicious or simply unhinged model can write os.remove(...) or worse, and the loop will happily run it. The custom-node world has already had its malware moment, and this is the same trust problem in a different costume - it's your own model doing the writing, but the execution risk is real. Keep execute_code off unless you fully trust the model and know what you're asking it to do. Also note it only applies to the transformers model path; GGUF models return plain text and never enter the code loop.

    Installing and gotchas

    Same pack install: ComfyUI Manager (search "LLM Node") or cd ComfyUI/custom_nodes && git clone https://github.com/Big-Idea-Technology/ComfyUI_LLM_Node, then restart. The gotcha that will actually bite: the default project_folder of /projects/LLM is a Unix path that almost certainly doesn't exist on Windows, and the copy step errors out if the folder isn't there. Create the folder first, or set it to something real.

    CategoryLLM

    Inputs (2)

    NameTypeDefaultDescription
    execute_codeBOOLEANfalse
    project_folderSTRING/projects/LLM

    Outputs (1)

    NameTypeDescription
    CodingConfigCODINGCONFIG