Nodes/TK Toolkit/TK Prompt Agent
ComfyUI Node

TK Prompt Agent

A chat box bolted to your graph that also checks its own homework

By Ararararararaki·Created 4 months ago·Updated 3 days ago· 40
TK Prompt Agent
  • image
  • agent_response
  • final_prompt
◄profileanima►
◄modecreate►
◄current_prompt►
◄user_instruction►
◄executionsnapshot►
◄session_id►
◄presetdefault►
◄custom_instructions►
◄locked_sections[]►
◄edit_scope[]►
◄approved_prompt►
◄agent_response►
◄approved_profile►
◄interrogation_sourcelocal-wd14►
◄interrogation_image►
◄interrogation_actionnone►
◄interrogation_options{}►
◄generation_strategydirect►

Most "prompt enhancer" nodes are a text box that calls an API and hands you whatever came back - preamble, markdown, Here is your enhanced prompt: and all. TK Prompt Agent is the same idea done with more paranoia: you chat at it in Chinese, it hands back a prompt formatted for the model you picked, and it refuses to emit anything that looks like chat.

It ships in TK Toolkit (Anima Toolkit before September 2026; the registry id anima-toolkit never changed), one author's answer to the housekeeping around anime generation. The Agent is the newest piece, added in 2.33.0.

What it actually does

The node carries a chat panel. Type "普通红狐狸在雪地里,晨光,低机位近景", hit Ctrl+Enter, then follow with "改成黄昏,角色不要动" - instructions edit a stateful session instead of starting over, and undo works. That alone beats re-typing into a text widget.

The call underneath is a plain Chat Completions request; no SDK, no bundled key. What makes it more than a wrapper is the two layers around it. The model isn't asked for a prompt, it's asked for JSON split into named sections (subject, character_identity, clothing, pose, camera, composition, lighting and six more). Then a local profile reassembles those sections in a fixed order, and a validator gates every fragment: per-profile lowercase and underscore handling, dedupe, an item budget, English-only, and hard rejection of markdown, code fences, brackets, URLs, </think>, and anything opening with "here is", "sure" or "prompt:".

That gate is the real product. Chat scaffolding leaking into your conditioning is the classic failure of this node category, and here it throws an error instead of quietly ruining the image.

The two profiles are genuinely different beasts. Anima is tag-style - lowercase Danbooru tags, and the instructions explicitly say not to add quality, score, style or artist boilerplate unless you asked. Krea 2 is prose - full sentences, capitalization kept, attributes tied to their subject, quoted text for on-image lettering. Pick the wrong one and you get a tag list for a model that wanted a paragraph.

The bits you actually set

Nine of the eighteen required widgets are state the panel writes back for you. The ones worth understanding:

profile and mode - which model's rules to apply, and what edit you're asking for (create, modify, expand, rewrite, convert, optimize). convert is what you need after switching profile.

current_prompt and user_instruction - the draft, and the change you want. Leave current_prompt empty and just describe the scene.

execution - snapshot (the default) means queueing reads the stored, approved prompt and does not call the API. execute means queueing runs the agent again, costs tokens, and moves the session forward. Iterate in the panel; only switch to execute when you want the graph to prompt itself.

locked_sections / edit_scope - JSON arrays that pin sections ("don't touch the character") or narrow the edit. The engine only honours these; it won't infer them from wording. generation_strategy picks direct write versus plan-then-write; the third option routes through your local DSH/Harness setup, which needs the optional mcp package.

Outputs

Two STRINGs. final_prompt goes into your CLIP Text Encode or text-encoder node - that's it. agent_response is the Chinese explanation of what changed. Don't wire that into an encoder; it's chat, not prompt.

Images: reverse-engineer a prompt

Connect the optional image (one at a time) and set interrogation_action to replace or append, and the node tags the image and folds the result into the session. Sources are local-wd14 (your own ONNX + CSV tagger, CPU by default, not downloaded for you), PixAI and ToriiGate (public Hugging Face Spaces, subject to queueing and HF account tier), or your configured vision connection. The optional expand step sends the photo and the tags to a vision model - the more useful half, since raw WD14 tags never describe composition.

Install

ComfyUI Manager, search TK Toolkit (registry id anima-toolkit), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Ararararararaki/comfyui-anima-toolkit

Restart ComfyUI. Required deps are just aiohttp and requests; the panel build ships in the repo, so no Node step. Optional extras (playwright, llama-cpp-python, mcp) sit in requirements-optional.txt. Then set your base URL ending at /v1, not /chat/completions, plus model and key in the advanced API settings. Keys live in local user config, never in the workflow file.

Where people get burned

Fresh node, snapshot mode, empty prompt = an error. Queue the graph before confirming a prompt and you get "Final Prompt 为空". Intentional, but it reads as a bug at 1am.

Switching profile without converting. There's an explicit guard: if approved_profile doesn't match profile, it refuses rather than silently reformatting your tags into prose.

The default proxy is http://127.0.0.1:7890. That's Clash. If you don't run a local proxy, clear it, or every hosted-API call fails while loopback services keep working and confuse you further. The default endpoint is DeepSeek's, so a fresh install with no key gets nowhere.

Reaching for a reasoning model. The job is "follow my section schema and stop talking" - a thinky model argues with the format and burns tokens doing it.

Don't confuse it with AnimaLoraToolkit / AnimaLoraAtelier - same prefix, different packs, those write training YAML. And like any API-backed node it ships nothing: keys, accounts and quota are yours.

CategoryTK/prompt

Inputs (19)

NameTypeDefaultDescription
profileCOMBOanima3 options: , anima, krea2
modeCOMBOcreate7 options: , create, modify, expand, rewrite, convert, +1
current_promptSTRING—
user_instructionSTRING—
executionCOMBOsnapshot3 options: , snapshot, execute
session_idSTRING—
presetSTRINGdefault—
custom_instructionsSTRING—
locked_sectionsSTRING[]—
edit_scopeSTRING[]—
approved_promptSTRING—
agent_responseSTRING—
approved_profileSTRING—
interrogation_sourceSTRINGlocal-wd14—
interrogation_imageSTRING—
interrogation_actionSTRINGnone—
interrogation_optionsSTRING{}—
generation_strategySTRINGdirect—
imageoptIMAGE—

Outputs (2)

NameTypeDescription
agent_responseSTRING—
final_promptSTRING—