• Bug Confirmed: {context} variable not substituted in prompt — RAG content never reaches OpenAI (MxChat Pro v3.2.10, Pinecone)

    Hello MxChat Support,

    I have been diagnosing a RAG issue on my installation and have now isolated the root cause with certainty. The {context} variable in the AI Instructions (Behavior) system prompt is not being substituted with retrieved knowledge base content before the prompt is sent to OpenAI. The model receives the literal string “{context}” instead of the actual retrieved text, sees no knowledge content, and correctly triggers the fallback response.

    SETUP

    • Plugin: MxChat Pro v3.2.10
    • WordPress: 6.9.4, GoDaddy Managed WordPress
    • Knowledge Base: Pinecone (Active, Connected)
    • Pinecone index: jvc-bot / AWS us-east-1 / Dense / 1536 dimensions / cosine metric
    • Embedding Model: Ada 2 (1536)
    • Chat Model: GPT-5.1 Chat Latest
    • Similarity Threshold: 85
    • RAG Sources Limit: 5
    • RAG Chunks Limit: 15
    • Citation Links: off
    • Contextual Awareness: off

    KNOWLEDGE BASE CONTENTS

    1. One manually entered Q&A entry: “How do I pair Bluetooth on the KD-X280BT?” with a clean 6-step answer
    2. One uploaded PDF: KW-M595BT/KW-M590BT instruction manual (56 pages, ~50 vectors)

    TEST CASE
    Query: “How do I pair Bluetooth on the KD-X280BT?”
    Expected: The 6-step Bluetooth pairing answer from the Q&A entry
    Actual: “I don’t have that specific information in my knowledge base, but I can connect you with dealer support or a specialist.”

    CONFIRMED ROOT CAUSE
    The Testing panel System Information section shows the assembled system prompt with {context} displayed as a literal unreplaced placeholder:

    “…Knowledge base context: {context}”

    The variable is not being substituted with the retrieved chunk content before the prompt is sent to OpenAI. The model receives an empty context block, sees no relevant knowledge, and triggers the fallback — which is the correct behavior given what it received. The prompt instructions themselves are working correctly. The failure is specifically in the variable substitution step.

    SUPPORTING EVIDENCE FROM NETWORK TAB (admin-ajax.php response JSON)
    All retrieval steps work correctly:

    • total_documents_checked: 50
    • Top match similarity: 94.62%
    • above_threshold: true
    • used_for_context: true
    • has_access: true
    • filtered_out: false
    • content_preview: contains the full correct answer text
    • sources_used: 2 (was previously 0, resolved after refreshing API keys)
    • total_chunks_used: 1

    Everything upstream of prompt assembly works. The retrieved content is present in content_preview. It is simply not being injected into the {context} placeholder before the OpenAI API call.

    WHAT I HAVE RULED OUT

    • OpenAI API key: replaced with a fresh active key, billing confirmed healthy ($0.11 of $100 limit used, 41 successful API calls this month)
    • Pinecone API key: replaced with a fresh key from the Pinecone dashboard
    • Pinecone index configuration: dimensions (1536), metric (cosine), region (us-east-1) all correct and consistent with Ada 2 embedding model
    • bot_id mismatch: all records tagged bot_id: “default”, consistent with single-bot Pro setup
    • System prompt formatting: tested multiple prompt variations including simple 4-line prompt. {context} variable is present and correctly placed in all versions. Variable substitution fails regardless of prompt complexity.
    • PDF chunk contamination: resolved by raising Similarity Threshold to 85, PDF chunks now correctly blocked (NOT USED), only the Q&A entry passes threshold
    • Similarity threshold: Q&A entry scores 94.62% consistently, well above threshold
    • Query phrasing: tested with exact KB entry phrasing including correct capitalisation

    CURRENT SYSTEM PROMPT (simplified version, same result with all variations tested):

    You are a JVC car audio support assistant.

    Answer the user’s question using ONLY the steps and information in the knowledge base context below. Do not add, expand, or invent any steps beyond what is written in the context.

    If the context contains a clear answer, reproduce it faithfully and completely — do not summarize or skip steps.

    If the context does not contain relevant information, say: “I don’t have that specific information in my knowledge base, but I can connect you with dealer support or a specialist.”

    Knowledge base context:
    {context}

    PLEASE INVESTIGATE
    The {context} variable in the AI Instructions (Behavior) field is not being substituted with retrieved Pinecone content before the prompt is passed to OpenAI. This appears to be a bug in the prompt assembly step of the mxchat_handle_chat_request handler. All retrieval, threshold, access, and filtering logic works correctly — the failure is only in the final injection of retrieved content into the prompt template.

    I am happy to provide temporary admin access to bobtherep.com, additional debug captures, or any other information needed to reproduce this.

    Thank you,
    Bob Connacher
    bobtherep.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support m4xw3ll

    (@m4xw3ll)

    hi @bconnacher,

    Thanks for reporting. I do believe i have this bug fixed already and ready for the next release. I will review everything closer to confirm and let you know.

    Thanks,

    Maxwell

    Thread Starter bconnacher

    (@bconnacher)

    Hello Maxwell!

    Please don’t take this the wrong way, but I’m starting a working vacation today, which just means I’m hiding from customers so I can get some work completed 😂, and one of the main things I wanted to get going was the RAG AI on my BobTheRep.com dealer support site. If Mxchat is not going to work for me because of this bug I will need to change to a new service and request a refund.

    Are there any workarounds we can use so I can stay with Mxchat, or do I need to find a new AI chatbot to use?

    I’m already familiar with your interface, so I would prefer to stick with it

    Regards,

    Bob

    Moderator Support Moderator

    (@moderator)

    Plugin: MxChat Pro v3.2.10

    @m4xw3ll Please do not support customers on this site again. That is not permitted.

    @bconnacher The developer cannot support the “pro”version here and will het into trouble if they do again.

    For pro or customer support, please contact the developer on their site. This includes pre-sales information.

    As the developer is aware, customers may not be supported on this site.

    https://wordpress.org/support/guidelines/#do-not-post-about-commercial-products

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘{context} variable not substituted in prompt’ is closed to new replies.