Nodes/ComfyUI-Autogen/Autogen Code Executor
ComfyUI Node

Autogen Code Executor

This node runs whatever the AI writes on your machine — sandbox it first

By strand1·Created 2 years ago·Updated 2 years ago· 3
Autogen Code Executor
    • code_executor_agent
    agent_namecode_executor
    working_directory/tmp/ComfyUI/custom_nodes
    timeout10

    AutogenCodeExecutor is the node that gives your agents hands. It wraps AutoGen's CodeExecutorAgent around a LocalCommandLineCodeExecutor, so when an assistant in your group chat decides "I should compute this myself," this agent actually writes and runs the Python on your machine and reports the result back. That's what turns a chat into an agent pipeline that can analyze stocks, scrape a search, and hand you a finished artifact.

    It's also the most dangerous node in this pack, and I mean that literally, not for drama.

    How it works

    When an assistant emits a message with executable code, the executor runs it with a local shell - no Docker, no sandbox, no virtual machine - using your user account's permissions. The working_directory defaults to ComfyUI's current working directory (usually the ComfyUI install folder), and timeout defaults to 10 seconds. There's an allow_network parameter lurking in the source, but it isn't exposed in the UI and isn't wired to anything, so don't look for a network kill-switch here: assume code runs however the OS allows.

    This is the same trust model as every custom node in the ecosystem - installing one is running arbitrary code, full stop (the ComfyUI_LLMVISION incident in 2024 is the canonical warning). With this node it's compounding: you're trusting both the pack and whatever the LLM decides to type. Practical rules: set working_directory to a dedicated throwaway folder, never point it at anything you care about, and don't feed it sensitive prompts or data.

    The inputs that matter

    • agent_name - a label, default code_executor. Keep it unique within a chat.
    • working_directory - where generated code runs and writes files. Change it from the default. This is the one you should actually touch.
    • timeout (1–60s, default 10) - per-execution cap. Slow tasks like the stock tool's data fetch will blow past 10 seconds, so raise it when your agent does real work.

    Output is code_executor_agent (type AGENT), meant for AutogenGroupChat. Note what it isn't: it doesn't chat. It executes and reports. Pair it with an AutogenAssistantAgent that decides what to run, and you have the classic research-loop: assistant reasons, executor computes, group chat stitches it together.

    Install

    Same as the rest of the pack - Manager, search "ComfyUI-Autogen", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/strand1/ComfyUI-Autogen
    cd ComfyUI-Autogen
    pip install -r requirements.txt
    

    Restart ComfyUI. The dependencies (autogen-core, autogen-ext[openai], autogen-agentchat) are heavy but plain pip. The tools your agent calls may need more - the example analyze_stock tool requires yfinance, pandas, and matplotlib in ComfyUI's Python env.

    Common issues

    Timeouts are the everyday failure: a 10-second default dies on any task that touches the network or pandas. Bump timeout and retry. File-location confusion is second - the example tool writes a stock chart to coding/ inside the working directory, so hunt for output files there, not next to your workflow. And the honest big one: this node runs uncontained code on your box. If that makes you uneasy, skip it and keep your agents chat-only, because the pack gives you no safety rail if things go sideways.

    CategoryAutogen

    Inputs (3)

    NameTypeDefaultDescription
    agent_nameSTRINGcode_executor
    working_directoryoptSTRING/tmp/ComfyUI/custom_nodes
    timeoutoptINT101–60

    Outputs (1)

    NameTypeDescription
    code_executor_agentAGENT