ComfyUI Node

Multimodal — Context handler

Assemble your LLM's background knowledge without a monster text block

By theonetwoone·Created 4 months ago·Updated 23 days ago· 1
Multimodal — Context handler
    • extra_context
    • extra_context_preview
    • STRING
    join_withdouble_blank_line
    include_titlestrue
    preview_chars1600
    block1_enabletrue
    block1_titleContext 1
    block1_sourcepreset
    block1_preset_filecharacter_sheet_template
    block1_text
    block1_file
    block2_enablefalse
    block2_titleContext 2
    block2_sourcepreset
    block2_preset_filecharacter_sheet_template
    block2_text
    block2_file
    block3_enablefalse
    block3_titleContext 3
    block3_sourcepreset
    block3_preset_filecharacter_sheet_template
    block3_text
    block3_file
    block4_enablefalse
    block4_titleContext 4
    block4_sourcepreset
    block4_preset_filecharacter_sheet_template
    block4_text
    block4_file

    The main LLM node's extra_context input is where your model's background knowledge goes - character sheets, style briefs, editing rules, the stuff the model should always have in front of it. Type it as one giant multiline blob and it's unreadable and unmaintainable. This node is the version-controlled, block-based assembler for that field: up to four toggleable blocks, each sourced from inline text, a file, or a preset, joined together into one extra_context string you feed to the LLM.

    How it works

    Each block is a mini-module with three source options: text (paste right in the block), file (a path to a .md/.txt - the file overrides the text field when set), or preset (one of the pack's presets/context/*.md files, e.g. character_sheet_template, image_prompting_flux, sdxl_negative_baseline, json_schema_contracts). You enable blocks 1–4 with blockN_enable, give them titles, and the node concatenates whatever's enabled, honoring include_titles (default true - titles become headers inside the context, which models genuinely use as anchors) and join_with (one or two blank lines between blocks). preview_chars (default 1600) truncates the preview so you don't get a 4,000-token wall of text in your face.

    Two outputs that matter: extra_context (wire to the LLM node) and extra_context_preview (read it on a Show Text node, or trust the in-node preview). The third output is a raw STRING that duplicates the assembled context - handy for chaining without fighting the widget graph.

    Why blocks beat a blob

    Because blocks compose. A realistic workflow: block 1 is your character sheet preset, block 2 is a .md file with the current story state that something else updates, block 3 is your style rules. You can enable/disable any of them per run, which is the entire point - one node, and "which background knowledge does this pass get?" becomes a checkbox question instead of an edit to a giant string. And like the system presets, the context preset dropdown scans presets/context/ at load, so you can drop your own .md templates in and they show up as options after a restart.

    The caveat is the standard one for context engineering: every enabled block eats into the model's context window, and a context stuffed with irrelevant background actively hurts small quantized models. Start with the character sheet, get the loop working, add blocks one at a time. preview_chars is your canary - if the preview is already a wall of text, the model is drowning too. This node doesn't decide what context is good; it just makes good context cheap to assemble and easy to audit.

    Categoryllm/multimodal

    Inputs (27)

    NameTypeDefaultDescription
    join_withCOMBOdouble_blank_line2 options: blank_line, double_blank_line
    include_titlesBOOLEANtrue
    preview_charsINT16000–20000
    block1_enableBOOLEANtrue
    block1_titleSTRINGContext 1
    block1_sourceCOMBOpreset3 options: text, file, preset
    block1_preset_fileCOMBOcharacter_sheet_template14 options: character_sheet_template, editing_invariants_checklist, image_prompting_flux, image_prompting_flux_kontext, image_prompting_sdxl, image_prompting_zimage, +8
    block1_textSTRING
    block1_fileSTRING
    block2_enableBOOLEANfalse
    block2_titleSTRINGContext 2
    block2_sourceCOMBOpreset3 options: text, file, preset
    block2_preset_fileCOMBOcharacter_sheet_template14 options: character_sheet_template, editing_invariants_checklist, image_prompting_flux, image_prompting_flux_kontext, image_prompting_sdxl, image_prompting_zimage, +8
    block2_textSTRING
    block2_fileSTRING
    block3_enableBOOLEANfalse
    block3_titleSTRINGContext 3
    block3_sourceCOMBOpreset3 options: text, file, preset
    block3_preset_fileCOMBOcharacter_sheet_template14 options: character_sheet_template, editing_invariants_checklist, image_prompting_flux, image_prompting_flux_kontext, image_prompting_sdxl, image_prompting_zimage, +8
    block3_textSTRING
    block3_fileSTRING
    block4_enableBOOLEANfalse
    block4_titleSTRINGContext 4
    block4_sourceCOMBOpreset3 options: text, file, preset
    block4_preset_fileCOMBOcharacter_sheet_template14 options: character_sheet_template, editing_invariants_checklist, image_prompting_flux, image_prompting_flux_kontext, image_prompting_sdxl, image_prompting_zimage, +8
    block4_textSTRING
    block4_fileSTRING

    Outputs (3)

    NameTypeDescription
    extra_contextSTRING
    extra_context_previewSTRING
    STRINGSTRING