EmAySee Context Writer V5
The watchdog writer — absolute paths, bounded history, and a truncation tripwire
- STRING
The last word in EmAySee's context-writer family is also the strictest. Context Writer V5 appends text to a file and trims the history to a maximum length - the same job as its sibling writers - but it adds three opinions the earlier nodes don't have: it demands an absolute path, it caps history with a max_history that defaults higher (4), and it throws an error if it sees the string [REASONING TRUNCATED] in the text you're appending.
That truncation guard is the personality of this node, and it tells you what it was built for. The pack's Oobabooga connector emits exactly that sentinel when a reasoning model's <think> block never closes - meaning the LLM's output was cut off mid-thought. Writing a truncated response into your context file would corrupt the history and poison every future turn. So this writer refuses: raise ValueError("CRITICAL ERROR: LLM Output was truncated. Workflow halted to prevent history corruption.") - a hard stop instead of silent data corruption. If you're building a long-running LLM loop, that tripwire is the difference between a log full of garbage and a workflow that tells you loudly that something broke.
How it works
The flow in py/EmAySee_ContextWriter_V5.py:
- Truncation guard - checks for the sentinel and raises if present.
- Path validation - creates the parent directory if it doesn't exist, so you can point it at a folder that's not there yet.
- Read existing history - splits the file on
---and keeps only blocks containingSTATE:. - Append - adds the new text.
- Prune - keeps the last
max_historyentries and rewrites the file.
Block delimiter is --- here (not the PROMPT:/STATE: regex of the other writers), and it does not auto-repair missing headers - it only filters blocks that have a STATE: when reading. Output is the appended text.
The inputs that matter
- file_path - default is the literal
/full/path/to/prompt_v2.txt, which is a placeholder, not a real file. You must set an actual absolute path (likeD:\comfy\context.txton Windows or/home/user/comfy/context.txton Linux). - text_to_append - the LLM output, forced as an input (no text box; wire it in).
- max_history (4, range 1–20) - how many blocks survive the prune.
Output: a single STRING - the appended text.
Install
Part of the EmAySee pack:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
Restart ComfyUI (or Manager → "ComfyUI_EmAySee_CustomNodes"). Category: EmAySee/Context (note: this one uses slash-separated "EmAySee/Context", unlike the "Automation/V5" of the Reader/Writer pair - the pack's category naming is not consistent).
Gotchas
The default file_path is a fake path - the first run will create a directory called /full/path/to/ if you forget to change it, so set a real absolute path first. The truncation guard is keyed to one exact sentinel string, so if a model outputs a differently-worded truncation marker it slips past - the guard is as strong as that string is exact. And the naming overlap is real: this node and the Context Writer (class EmAySee_ContextWriter) both display as "Context Writer V5" in the menu but are different code with different path handling and different guard behavior. Read the class names in the briefs or source before you wire one in. Hobbyware, no support - but of all the context writers, this one has the clearest idea of what it wants and the most useful failure mode.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | /full/path/to/prompt_v2.txt | — |
| text_to_append | STRING | — | |
| max_history | INT | 41–20 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |