Set Role
Stop retyping the same system prompt — make it a dropdown instead
- system_prompt
- role_name
- resolved_index
If you've run an LLM node in ComfyUI - an Ollama call, a captioner, a style transform - you've hit the same wall: every workflow wants a different long system prompt, and that wall of prose lives in a text box on the node. Paste it in wrong once and your "translator" quietly becomes a "summarizer." Set Role (class LLMSetRole) is a tiny fix for that: a dropdown of system-prompt roles stored as Markdown files, which spits out the selected role's text as a STRING you wire straight into any LLM node's system_prompt input. That's the whole node. There's nothing else, and that's kind of the point.
One thing to clear up first: the name makes it sound like it's setting a role inside a chat model or calling some API. It isn't. No key, no endpoint, no model download, no network call of any kind. It reads a file off disk and hands you the contents. The "role" is just the system prompt you wrote, saved with a name.
How it works
The node scans a roles/ directory inside the pack folder at startup and builds a dropdown from every *.md file there. Pick a role, and the node returns the file's contents verbatim as the system prompt. The mechanism is deliberately boring: scan, sort, read, output. There's an mtime fingerprint behind the scenes, which means one nice behavior - if you edit an existing role file, the node picks it up on the next run without a restart. Only adding a new file needs a restart, because the dropdown options are built once at import.
To add a role: drop a .md file into roles/ (there's an example.md.example showing the format) and restart ComfyUI. The dropdown label defaults to the prettified filename - summarizer.md becomes "Summarizer." Want a specific label? Make the first line an HTML comment like <!-- title: Concise Summarizer -->; that line is stripped from the output and used only as the label. Nice touch: your roles/*.md files are gitignored, so your prompts stay private if you ever share the repo.
The inputs and outputs that matter
There's exactly one input, and it's the whole node:
- role (combo) - the role whose Markdown becomes the system prompt. This is the widget you actually touch, and it has a genuinely useful trick: it carries ComfyUI's
control_after_generatecontrol, the same one samplers put onseed. Set it to fixed to hold the role, increment wrap to advance one role per generation and loop back around, or randomize to pick one at random. That turns a batch run into an automatic pass through every role you've defined - handy for A/B testing prompts.
Three outputs, all straightforward:
- system_prompt (STRING) - the full text of the selected role file. Wire this into an LLM node's
system_promptinput (it pairs naturally with thestavsap/comfyui-ollamapack). - role_name (STRING) - the selected role's display name, handy for logging or filename suffixes.
- resolved_index (INT) - the role's position in the alphabetically sorted list, for labelling batched runs.
Installing it
ComfyUI Manager is the easy route: Manager > Custom Nodes Manager, search for ComfyUI_LLMSetRole, install, restart. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/bradsec/ComfyUI_LLMSetRole
Then restart ComfyUI. The good news for your dependency hell: there are no dependencies. Zero. Python stdlib only - no requirements.txt at all, so it can't break your environment. You'll find it under Add Node > LLM as Set Role.
Where people get burned
The classic gotcha: you install it, open the node, and the dropdown reads "(no roles found)." That's not a bug - the pack ships no actual roles, only the .md.example template. Add your first .md file and restart. If you create a role file and it doesn't show up, same fix: the list is built at startup, so new files need a restart even though edits don't.
Is it worth it for one workflow? Probably not. But if you run half a dozen LLM workflows that reuse the same system prompts, turning them into version-controllable files you can step through in a batch is genuinely nicer than five text boxes drifting out of sync. Tiny, boring, and does one thing well.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| role | COMBO | (no roles found) | The role whose Markdown becomes the system prompt. Set this widget's control_after_generate to step roles across a batch: 'fixed' holds it, 'increment wrap' advances one role per generation and wraps around, 'randomize' picks at random. The list is built from roles/*.md at startup; add a .md file and restart ComfyUI to add a role. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| system_prompt | STRING | — |
| role_name | STRING | — |
| resolved_index | INT | — |