query
Answer questions by retrieving relevant knowledge-graph context, returning cited answers with source references.
Instructions
Answer a question using the knowledge base (RAG). Use this for any
question about the content stored in LightRAG -- it retrieves relevant
context and has an LLM compose the answer. Returns response (the
answer text) and, by default, references (the source documents it
drew on).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Retrieval mode. 'mix' (default) combines knowledge-graph and vector retrieval and is the best general-purpose choice. 'local' favors entities near the query, 'global' favors relationships, 'hybrid' combines local+global, 'naive' is plain vector search, and 'bypass' skips retrieval entirely and sends the query straight to the LLM. | mix |
| query | Yes | The question or instruction to answer using the knowledge base. Must not be empty. | |
| top_k | No | Number of top items to retrieve: entities in 'local' mode, relationships in 'global' mode. | |
| chunk_top_k | No | Number of text chunks to retrieve and keep after reranking. | |
| hl_keywords | No | High-level keywords to prioritize in retrieval. Leave empty to let LightRAG derive them. | |
| ll_keywords | No | Low-level keywords to refine retrieval focus. Leave empty to let LightRAG derive them. | |
| user_prompt | No | Extra instructions for the answering LLM. Does not affect retrieval. | |
| enable_rerank | No | Enable reranking of retrieved text chunks, if a rerank model is configured. | |
| response_type | No | Desired response format, e.g. 'Multiple Paragraphs', 'Single Paragraph', 'Bullet Points'. | |
| max_total_tokens | No | Maximum total token budget for the whole query context (entities + relations + chunks + system prompt). | |
| only_need_prompt | No | Return only the assembled prompt, without calling the LLM. | |
| max_entity_tokens | No | Maximum tokens allocated to entity context. | |
| only_need_context | No | Return only the retrieved context, without generating an answer. | |
| include_references | No | Include the list of source documents the answer drew on. Keep this true (the default) so answers can cite which document they came from. | |
| max_relation_tokens | No | Maximum tokens allocated to relationship context. | |
| conversation_history | No | Prior turns for context only (not used for retrieval), as [{'role': 'user'|'assistant', 'content': '...'}, ...]. | |
| include_chunk_content | No | Include the actual chunk text in each reference (for debugging/evaluation); only applies when include_references is true. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||