AI Assistant Optimization Consultant
Build an AI Assistant Optimization Consultant that automatically diagnoses AI response quality issues and provides adjustment recommendations for prompts and knowledge base documents
Overview
When an AI assistant produces inaccurate answers, formatting errors, hallucinated information, or other issues, it typically requires manual review of conversation records to locate problems. The Optimization Assistant can automate this diagnostic process:
Automatically retrieve conversation records, AI responses, and knowledge base retrieval results
Determine whether the issue is a Prompt Problem (AI received the right data but answered incorrectly) or a Knowledge Base Document Problem (AI didn't receive the right data)
Generate specific modification recommendations with Before / After comparisons
Components
AI Assistant
Serves as the carrier for the optimization consultant, using Agent mode
Role Instructions
Defines the diagnostic process, analysis principles, and output format
MCP Tool
Allows the optimization assistant to call the MaiAgent API to query conversation records and assistant configurations
Knowledge Base
Bound to the knowledge base used by the target assistant, for verifying RAG retrieval results
Prerequisites
Assistant to Analyze
The target AI assistant you want to optimize
Admin Console → AI Assistant List
Target Assistant's Knowledge Base
The knowledge base attached to the target assistant
Click the target assistant → Knowledge Base tab
API Key
For MCP tool authentication
Profile → API Keys (see instructions below)
Step 1: Create an AI Assistant
Left sidebar → AI Assistants → Click Create AI Assistant
Fill in basic settings:
Name
Optimization Assistant or AI Assistant Optimization Consultant
LLM Model
Claude Sonnet 4.6 or above (requires strong analytical reasoning capabilities)
Switch to the Response Mode Settings tab, select Agent Mode
Response mode must be set to Agent Mode. RAG Q&A mode cannot use MCP tools, which will prevent the optimization assistant from querying conversation records and assistant configurations.
Click Save
Step 2: Set Up Role Instructions
In the same page's Response Mode Settings tab, find the Role Instructions section below
Paste the following standard role instructions in full
The role instructions are the core of the optimization assistant, defining the diagnostic process, seven optimization principles, and output format. It is recommended to use the standard version as-is without modification.
Click Save
Step 3: Create MCP Tool
The MCP tool allows the optimization assistant to query the MaiAgent API to retrieve conversation records and assistant configurations.
Left sidebar → Tools → Click Add Tool in the upper right corner
Switch the Tool Type from API to MCP
Fill in the following settings:
Display Name
MaiAgent API
Description
AI Response Analysis Tool
MCP Tool URL
https://mcp.maiagent.ai/mcp
After creation, go to the assistant settings → Tools tab to see the bound MCP tool
Authentication Headers (MCP Headers) — Enter the following JSON:
How to obtain an API Key?
Click the avatar in the upper right corner → Profile → Switch to the API Keys tab → Click Create New Key, and copy the generated API Key.
The API Key is only displayed once after creation. Copy and store it securely immediately.
Allowed Tools — Check the following 5:
debug_auth
Verify authentication is correct
list_api_categories
List API categories
search_apis
Search API endpoints
get_api_details
Get API detailed specifications
call_api
Execute API calls
Tool Prompt — Paste the following content in full:
Click Save
Step 4: Bind Knowledge Base
The optimization assistant needs to bind the knowledge base used by the target assistant to verify RAG retrieval results during diagnosis.
Switch to the Knowledge Base Settings tab
Click Add Knowledge Base and check all knowledge bases used by the target assistant
Click Save
If you need to analyze multiple AI assistants, bind all their knowledge bases to the optimization assistant. It is recommended to set the retrieval chunks count to 12 in "Advanced Settings".
Step 5: Verify Setup
Verify MCP Tool Connection
In the optimization assistant's chat box, enter:
The optimization assistant should successfully call debug_auth and return authentication information.
Verify Diagnostic Functionality
Obtain a conversation_id from the target assistant's conversation records:
Go to the All Conversations page
Click any conversation; the ID in the URL is the conversation_id
In the optimization assistant, enter:
The optimization assistant will automatically execute the following steps in order:
Search for available API tools (
search_apis)Call
v1MessagesListto query conversation messagesCall
v1RecordsRetrieveto get conversation record detailsCall
v1ChatbotsRetrieveto get the analyzed assistant's PromptProduce a complete diagnostic summary and modification recommendations
Usage Guide
Analyze by conversation_id
The optimization assistant will automatically retrieve conversation records, AI responses, knowledge base retrieval results, and assistant prompts to produce a complete diagnostic report.
Analyze by Pasting Text Directly
If you don't have a conversation_id, you can provide the information directly:
Interpreting Diagnostic Results
Prompt Problem
AI received the right data but the response approach is wrong
Modify role instructions or Skills per recommendations
Knowledge Base Document Problem
Document structure caused AI to retrieve incorrect content
Rewrite knowledge base documents per recommendations
Knowledge Base Gap
Knowledge base simply doesn't have relevant content
New knowledge base documents need to be added
FAQ
Q: What should I do if the MCP tool connection fails?
Confirm the response mode is Agent Mode (most common cause)
Confirm the API Key is valid and not expired
Confirm the MCP URL is
https://mcp.maiagent.ai/mcpConfirm Headers use the
Api-Keyformat (e.g.,Api-Key xxxxxxxx.xxxxxxxx)
Q: Can one optimization assistant analyze multiple assistants? Yes. As long as the API Key belongs to the same organization and all target assistants' knowledge bases are bound.
Q: Do I need to create one for each client? Yes. Each client organization needs its own optimization assistant, since API Keys and knowledge bases are organization-specific.
Setup Checklist
Bind target assistant's knowledge base
Verify MCP connection
Verify diagnostic functionality
Last updated
Was this helpful?
