EmAySee Context Writer V5
Context Writer V5 — the append half that fixes your LLM's headers for you
- STRING
If Context Reader V5 is the read half of EmAySee's file-based LLM memory, Context Writer is the write half: it takes whatever an LLM just generated, appends it to the context file, and keeps only the most recent entries so the file doesn't balloon forever.
But here's the detail that makes this node worth a second look: it repairs the text before it writes it. The V5 context format expects every block to start with PROMPT: and contain a STATE: header - and LLMs, left to their own devices, will give you neither. The Writer checks, and if the headers are missing it prepends PROMPT: to the text and appends STATE: [Repaired Placeholder] to it before saving. That's the exact failure mode that made the earlier Context Manager nodes silently return nothing on read, fixed at the write end so the round-trip actually works.
It also deduplicates: if the last block already starts with the same 100 characters as the new generation, it skips the write instead of appending a near-identical copy. And it's marked as an output node in ComfyUI, so it has that special output-node styling in the graph.
How it works
The implementation (in py/EmAySee_ContextManagerRWNodes_V3.py, which defines the Reader and Writer together) resolves file_name relative to the ComfyUI root, reads the existing blocks with the PROMPT:/STATE: regex, runs the header-repair and dedupe checks, appends, then prunes to the last history_count blocks and atomically rewrites the file. The returned STRING is the new generation text, so you can keep it flowing through the graph if you want.
The inputs that matter
- file_name (default
user/default/emaysee_prompts/prompt_v2.txt) - same default as the Reader, so the pair works together with zero config. - history_count (2) - how many blocks survive the prune.
- seed - present for parity with the Reader; doesn't change what gets written.
- new_generation (optional) - the LLM output to append. If empty, the node returns
("",)and writes nothing.
Output: a single STRING - the text that was appended.
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/Automation/V5.
Gotchas
The header repair is helpful but rough - the placeholder state is literally [Repaired Placeholder], which your Reader will happily feed back to the LLM as part of the context. Expect to see that string in your context now and then; it's cosmetic. Also, don't confuse this node with the standalone Context Writer V5 (class EmAySee_ContextWriter_V5), which is a separate, later node that takes an absolute file_path, has no header repair, and raises an error if it sees [REASONING TRUNCATED] in the text - a sentinel this pair's sibling nodes emit when an LLM answer gets cut off. Both are called "Context Writer V5" in the menu, which is about as confusing as it sounds. Read the file format in the source before you hand-edit anything. Hobbyware, no support - but the auto-repair makes this the most forgiving of the pack's context writers.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| file_name | STRING | user/default/emaysee_prompts/prompt_v2.txt | — |
| history_count | INT | 21–10 | — |
| seed | INT | 00–18446744073709550000 | — |
| new_generationopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |