For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

  1. Automatically retrieve conversation records, AI responses, and knowledge base retrieval results

  2. 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)

  3. Generate specific modification recommendations with Before / After comparisons

Components

Component
Description

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

Item
Description
How to Obtain

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

  1. Left sidebar → AI Assistants → Click Create AI Assistant

  2. Fill in basic settings:

Field
Recommended Value

Name

Optimization Assistant or AI Assistant Optimization Consultant

LLM Model

Claude Sonnet 4.6 or above (requires strong analytical reasoning capabilities)

  1. Switch to the Response Mode Settings tab, select Agent Mode

  1. Click Save


Step 2: Set Up Role Instructions

  1. In the same page's Response Mode Settings tab, find the Role Instructions section below

  2. 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 to expand: Standard Role Instructions
  1. 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.

  1. Left sidebar → Tools → Click Add Tool in the upper right corner

  2. Switch the Tool Type from API to MCP

  3. Fill in the following settings:

Field
Value

Display Name

MaiAgent API

Description

AI Response Analysis Tool

MCP Tool URL

https://mcp.maiagent.ai/mcp

  1. After creation, go to the assistant settings → Tools tab to see the bound MCP tool

  2. 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.

  1. Allowed Tools — Check the following 5:

Tool
Purpose

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

  1. Tool Prompt — Paste the following content in full:

Click to expand: Standard Tool Prompt
  1. 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.

  1. Switch to the Knowledge Base Settings tab

  2. Click Add Knowledge Base and check all knowledge bases used by the target assistant

  3. 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:

  1. Go to the All Conversations page

  2. 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:

  1. Search for available API tools (search_apis)

  2. Call v1MessagesList to query conversation messages

  3. Call v1RecordsRetrieve to get conversation record details

  4. Call v1ChatbotsRetrieve to get the analyzed assistant's Prompt

  5. Produce 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

Diagnosis Type
Meaning
Next Steps

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?

  1. Confirm the response mode is Agent Mode (most common cause)

  2. Confirm the API Key is valid and not expired

  3. Confirm the MCP URL is https://mcp.maiagent.ai/mcp

  4. Confirm Headers use the Api-Key format (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

Last updated

Was this helpful?