How does LlamaIndex ChatEngine differ from QueryEngine?
QueryEngine is stateless retrieve and synthesize; ChatEngine adds conversation memory and can rewrite underspecified follow-ups into standalone queries before retrieval.
Picture a research assistant at a library. The QueryEngine version is the desk attendant. You walk up, ask one question, they pull a book, read you the relevant page, you leave. Every visit starts fresh; they do not remember you. The ChatEngine version is a personal researcher you book by the hour. They remember what you asked last time. When you say 'and what about its side effects?', they know 'its' means the drug you discussed three minutes ago, and they rewrite the question into something they can actually search before pulling the next book. The difference is memory and follow-up rewriting, not the books or the search.
Detailed answer & concept explanation~5 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: QueryEngine vs ChatEngine, the three ChatEngine modes, the antecedent-resolution failure mode, and how to pick a mode.
| Axis | QueryEngine | ChatEngine |
|---|---|---|
| State | Stateless per call | Conversation memory across turns |
| Turn handling | Literal query → retrieve → synthesize | Mode-dependent (condense / context / react) |
| Follow-up rewriting | No | Yes in condense_question mode |
| Tool-calling option | No (just retrieve) | Yes in react mode |
| Cost per turn | 1 retrieval + 1 synthesis | Up to 1 rewrite + 1 retrieval + 1 synthesis |
| Best fit | Search box, single-turn Q&A | Multi-turn chatbot with referential follow-ups |
Real products, models, and research that use this idea.
- LlamaIndex's documentation chatbot uses ChatEngine in `condense_question` mode because doc questions chain into 'how does this interact with X' follow-ups.
- Notion AI and Linear's assistant patterns rely on the agentic mode equivalent. Retrieval as a tool, not as the default action per turn.
- QueryEngine alone backs many 'search-over-PDFs' single-turn demos where each query is independent.
- LangChain's ConversationalRetrievalChain solves the same problem with a similar two-step rewrite then retrieve flow under different naming.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you decide between condense_question and react?
QWhat happens to the condensed query in condense_question mode if the history is misleading?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Using QueryEngine for a chatbot and discovering that follow-up questions like 'and what about its side effects?' retrieve garbage because the pronoun gets embedded with no antecedent.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.