In a RAGFlow chat assistant's system prompt, what does the {knowledge} variable do?
answer
- a placeholder, not a setting
- the prompt engine's system prompt template
- substituted just before the model call
- delete it and nothing errors
- retrieval still runs, chunks never arrive
basics
~20 s{knowledge} is the placeholder RAGFlow fills with the retrieved chunks before calling the model. Remove it from the assistant's system prompt and retrieval still runs, but no document text ever reaches the LLM, so answers stop being grounded.
solid answer
~50 sA RAGFlow chat assistant has a prompt-engine configuration whose system prompt is a template. `{knowledge}` is the reserved variable in that template: at request time RAGFlow retrieves chunks from the attached knowledge bases, formats them, and substitutes them at that position before sending the prompt to the model. Everything around it — the role, the tone, the instruction to answer only from the supplied material and to admit when it is not there — is yours to write. You can also declare additional variables in the same configuration and supply their values per request through the API, which is how one assistant serves several tenants or personas. The important operational fact is that deleting `{knowledge}` does not disable retrieval or raise an error; it silently produces a plain chat model with no documents, which looks like hallucination rather than misconfiguration.
code
python · 10 linesSYSTEM_PROMPT = """You are a support assistant for the billing product.
Answer only from the material between the markers.
--- knowledge base ---
{knowledge}
--- end ---
If the answer is not in that material, say you do not know."""
print(SYSTEM_PROMPT.format(knowledge="<retrieved chunks are substituted here>"))go deeper
Know that the assistant's system prompt is a template and that {knowledge} is where the retrieved chunks are inserted. Be able to say what happens to grounding if it is missing.
Explain the substitution point in the request flow, the difference between retrieval-filled and caller-supplied variables, and why a missing placeholder is a silent failure rather than an error.
Demonstrate the debugging instinct: check the template before blaming the embeddings, and pair the template's refusal instruction with a configured empty response so 'nothing retrieved' is observable.
Treat the template and the retrieval settings as one versioned artefact per assistant, with review and regression queries, so nobody edits a prompt into an ungrounded chatbot and ships it unnoticed.
## Where it lives A RAGFlow chat assistant is configured in three parts: the assistant settings (name, opening greeting, empty response, whether to show quotes), the prompt engine, and the model settings. The prompt engine holds the system prompt template plus the retrieval controls that assistant will use — similarity threshold, keyword similarity weight, top N, and optionally a rerank model. The system prompt is a template, not a fixed string, and `{knowledge}` is its reserved slot. ## What substitution actually does On each user turn RAGFlow retrieves from the knowledge bases attached to the assistant, applies the threshold, keeps the top N surviving chunks, and renders them into text. That rendered block replaces `{knowledge}` in the template. The assembled system prompt then goes to the configured model along with the conversation. So the template is where you control everything about how the model is allowed to use the retrieved material: whether it may add outside knowledge, what to do when the block is thin, what format the answer takes, what language to answer in. The retrieval settings decide *which* chunks land in the slot; the prose around the slot decides what the model does with them. ## Other variables `{knowledge}` is the built-in one, but the same configuration screen lets you declare additional named variables. Those are filled per request from the API rather than by retrieval, which is the mechanism for parameterising one assistant across callers — a customer name, a product line, a locale — without cloning the assistant per case. A declared variable that the caller never supplies leaves you with an unfilled template, so keep the declared set and the caller contract in sync. ## The silent failure The single most common mistake is rewriting the system prompt to something more elaborate and dropping the placeholder in the process. Nothing errors. Retrieval still runs and still costs you embedding and search work. The reference list may even still be produced. But the model never sees a document, so it answers from its own parameters — confidently, fluently, and wrongly, in exactly the register that reads as hallucination. Anyone debugging "our RAG is hallucinating" should check the template for the placeholder before touching thresholds or embeddings. ## Interaction with the empty-response setting The assistant settings include an empty response. If retrieval returns nothing that clears the threshold, that fixed text is returned instead of calling the model. Left blank, the model is called anyway with an empty knowledge block and answers unaided. Combining a written empty response with an explicit instruction inside the template — answer only from the material above, and say plainly when it is absent — is what turns "no relevant documents" into a visible, testable outcome rather than a fabricated answer. ## Writing the template well Keep the instructions ahead of the slot and the constraints after it, so the model reads the rules, then the material, then the reminder. Delimit the block visibly. State the refusal rule in one sentence rather than three hedged ones. And keep the template under version control alongside the retrieval settings, because an assistant's behaviour is the pair — a template tuned for six rich chunks behaves differently when someone drops top N to two.
- How would you prove that the placeholder is actually being filled on a live assistant?Ask a question whose answer exists only in the documents and cannot be guessed — an internal ticket number, a table value, a bespoke policy limit — and see whether the answer is right and whether the returned references contain the chunk. Then replay the same query in the knowledge base's retrieval-testing panel with the assistant's threshold and weight. Matching chunks in the panel plus a correct answer means substitution is working.
- What is the difference between the {knowledge} variable and the extra variables you can declare on the same screen?`{knowledge}` is filled by RAGFlow's retrieval step on every turn. Declared variables are filled by the caller in the API request, so they carry per-request context — tenant, product, language — that has nothing to do with the knowledge bases. One is populated by the pipeline, the other by the client, and a declared variable the client omits leaves the template unfilled.
saying these in an interview costs you the question
- Thinks removing {knowledge} disables retrieval or raises an error
- Believes chunks are appended automatically wherever the placeholder is
- Confuses the retrieved-chunk variable with caller-supplied prompt variables
- Says the placeholder must appear in every document's metadata
- Assumes citations still ground the answer when the placeholder is missing