build_rag_prompt
Assemble a complete RAG (Retrieval-Augmented Generation) prompt from retrieved context chunks and a user query. Handles token budgeting, citation numbering, system instruction injection, and source attribution.
Example tool call
This call uses example arguments supplied in the tool’s input schema.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "q?",
"chunks": [
{
"text": "c1 text",
"source": "a.md"
}
]
},
"name": "build_rag_prompt"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The user question to answer | |
| chunks | Yes | Retrieved context chunks with .text (required), .source (optional), .score (optional) | |
| language | No | Response language instruction (e.g. "French", "Spanish") | |
| cite_sources | No | Add [1], [2] citation numbers (default: true) | |
| max_context_tokens | No | Max tokens for context section (default: 2000) | |
| system_instruction | No | Custom system instruction (default: standard RAG grounding instruction) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | No | ||
| system_prompt | No | ||
| chunks_included | No | ||
| included_chunks | No | ||
| chunks_truncated | No | ||
| total_tokens_estimate | No | ||
| context_tokens_estimate | No |