Simple LLM: Agent with Rules
Your guardrails are just system prompt surgery
- config
- AGENT
Want an agent that stays on topic, refuses harmful requests, and never forgets your formatting demands? Every LLM framework has a mechanism for that, and they all secretly do the same thing: they shove your rules into the system prompt and hope the model complies. Simple LLM: Agent with Rules is this pack's version, and it doesn't pretend otherwise - the rules get pasted straight into the system prompt as bullet points. What you gain is convenience: you don't have to hand-assemble that string yourself.
This node lives in the SimpleLLM family of ComfyUI-NS-Util (NakamuraShippo's utility pack), an actively-developing corner of the pack - the README flags the LLM section as "Implementing the tests now." It builds on a config from any of the Simple LLM Config nodes (OpenAI, Claude, Gemini, or Ollama).
How it works
You hand it an LLM_CONFIG, a system_prompt, and a rules block. The node splits rules on newlines, turns each non-empty line into a - rule bullet, and appends the whole thing to your system prompt under a "You must follow these rules:" header. The result is an AGENT whose system prompt is your base persona plus your rule list - ready to feed into Simple LLM Run: Prompt.
So the mechanism is text assembly, not enforcement. The model follows your rules as strongly as it follows anything else in its system prompt, which is to say: usually, but not reliably. Keep rules short, concrete, and few. "3. Stay on topic" is weaker than "3. If asked about unrelated topics, say you only handle X."
The inputs that matter
- config - the LLM_CONFIG from a Simple LLM Config node. Pick the provider, model, and temperature here.
- system_prompt - your base persona. This is the character; the rules are the guardrails.
- rules - the default is a generic three-liner ("Be helpful and accurate", "Avoid harmful content", "Stay on topic"). Replace it with your constraints. Each line becomes a bullet, so line breaks are how you structure rules.
Output is a single AGENT, which you wire into Simple LLM Run: Prompt to actually generate text.
Installing the pack
# ComfyUI Manager → Install via Git URL:
https://github.com/NakamuraShippo/ComfyUI-NS-Util
# or:
cd ComfyUI/custom_nodes
git clone https://github.com/NakamuraShippo/ComfyUI-NS-Util
pip install pyyaml watchdog
Restart ComfyUI. No model files, no heavy dependencies - just the pack's own pyyaml/watchdog requirements plus the Python that ships with ComfyUI. ComfyUI 0.3+ recommended.
Common issues
Since the rules are just appended text, the classic failure is contradiction: a rule that fights your system prompt ("You are an unfiltered assistant" + "Avoid harmful content") produces an agent with whiplash. Write rules that extend the persona instead of contradicting it.
If the agent ignores rules entirely, remember they're soft constraints - bumping them up-front or tightening the wording changes behavior more than adding rule #12. And as with the whole SimpleLLM family, expect rough edges; this is the newest, least-battle-tested part of the pack.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| config | LLM_CONFIG | — | |
| system_prompt | STRING | — | |
| rules | STRING | 1. Be helpful and accurate 2. Avoid harmful content 3. Stay on topic | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| AGENT | AGENT | — |