Debugging and understanding AI customer service prompts from the perspective of the main and sub-agents

Core insight: More prompts aren’t always better. Identifying which stage of a reply went wrong, and then writing rules where they belong, is often more effective than endlessly stacking restrictions.

This article discusses the division of responsibilities among “Role,” “Communication Style,” “Conditional Adherence,” and “AI Skills” in an AI customer service system that uses a “Main Agent + Sub Agent” collaboration mechanism.

1. How is an AI customer service reply generated?

Before understanding prompts, first understand the complete execution chain:

Customer message → Main Agent understands the issue → Generates task input and selects subtask → Sub Agent executes AI skill → Generates task output → Main Agent integrates output → Final reply to customer.

Here are four easily confused concepts:

  • Main Agent: Understands the customer’s issue and conversation context, decides which task to invoke, organizes task input, and processes the results returned by subtasks.

  • Task Input: The execution materials organized by the Main Agent for the Sub Agent. It may include the customer’s original words, historical conversation, memory, image recognition results, knowledge base information, and the Main Agent’s semantic judgments. It is not synonymous with the customer’s original words.

  • Sub Agent: Completes the current business processing and generates task output based on the task input and the rules within the corresponding AI skill.

  • Task Output and Final Reply: What the Sub Agent returns is an intermediate result; the Main Agent may further merge, filter, simplify, or rewrite it. The content finally sent to the customer may differ from the task output.

Therefore, an inaccurate final reply does not necessarily mean the AI skill was written incorrectly.

2. When a reply is wrong, first locate which layer the issue occurred in

It is recommended to troubleshoot from front to back along the execution chain, rather than directly adding restrictions to all prompts.

Troubleshooting Stage Common Issues Priority Areas to Check or Modify
① Customer message → Task input Main Agent misunderstands business, misses conditions, misinterprets screenshots, or confuses different messages Conditional Adherence, Communication Style
② Task input → Subtask selection Task input is correct, but an inappropriate AI skill was invoked Trigger conditions in Conditional Adherence, Trigger conditions in AI Skills
③ Subtask execution → Task output Skill invocation is correct, but processing steps, judgments, or reply content are incorrect Corresponding AI Skill, Tool results
④ Knowledge base retrieval No relevant content retrieved, or retrieved content does not match the customer’s question Retrieval Query, Knowledge base content, Data validity and permissions
⑤ Task output → Final reply Subtask output is correct, but the Main Agent incorrectly deletes, overwrites, or rewrites it Final reply handling rules in Conditional Adherence

Troubleshooting order: First compare with the customer’s original words, then examine the task input, the skill actually invoked, the task output, the final reply, and the sending records. Find the earliest point of deviation and modify that stage.

3. Case 1: The task input was misunderstood from the start

For example, a customer sends a screenshot of a fitness short video, where topics like #SweatSpace can be identified.

The Main Agent might organize the following information in the task input:

•        Task Input: Full chat log original text:
​
•        Customer Service: .
​
•        Customer: [Short video screenshot, image link https://assets.xinheyun.com/static/2026-10-15/f_176118714122326016.png (repeating link for the same image)] [Image content (content obtained from image recognition, please use reasonably in the answer)]
​
•        \- Image type: Short video APP interface screenshot. The video frame shows two men holding dumbbells in a gym.
​
•        \- OCR Text: Status bar 13:56; Battery 70; Search what you want to see; Search; Still giving away seven days of free training!; Likes 1053; Comments 12; Favorites 3; Shares 4; 0.8km | SweatSpace Fitness All-in… · Group Buy Deal; Group Buy Refundable Anytime · Valid at Multiple Stores; @ChengduXiaoDu; March 16; Two people for 60+, personal training classes, plus 7 days of free training!; #ChengduXiaoDu #SweatSpace #Fitness #GoodShape… Expand; Loveable comments, say something nice.
​
•        Current Time: 2026-10-15 15:56:22 Thursday.
​
•        Semantic Completion for This Round: Customer sent a fitness short video screenshot containing the #SweatSpace topic, but did not specify inquiry or redemption intent.
​
•        Actually Visible Image: Two men holding dumbbells, background training rack, barbell plates, equipment; Topic area highlighted in red box, confirming #ChengduXiaoDu #SweatSpace #Fitness #GoodShape, subsequent content folded and unconfirmable; Currency unit for text amount unconfirmable; Date year unconfirmable; Complete store list for group buy unconfirmable. Not an order screenshot, nor a user comment screenshot. Heart and star icons are interaction buttons and cannot serve as evidence of the comment platform or star rating. The publishing account is not a confirmed customer account.
​
•        Context Memory: Brand only appears in image as SweatSpace, customer has not confirmed brand or unique store, intent is unclear; No customer city information, cannot infer from ChengduXiaoDu. Information clearly informed to customer: Only customer service original text '.', no business explanation.
​
•        Key Facts from Previous Knowledge Base Return: Search did not match video topic sharing activity description; Returned "Reward for Good Review" requires screenshot of personal 5-star comment, "3-day gift card" requires venue card purchase order. Current image does not belong to these vouchers; Must not arbitrarily determine activity qualification or personal training intent. Store and requirements are missing, please prioritize only asking for store information.

This type of task input preserves confirmed facts and unconfirmed information, helping the Sub Agent make correct judgments.

If the Main Agent directly interprets the screenshot as “Customer has met the redemption conditions,” subsequent processing might continue along the wrong premise, even if the correct skill is invoked.

Here, it is especially important to distinguish three layers of information:

  1. Content that actually exists in the customer’s original words or image;

  2. Facts that can be reasonably judged based on context;

  3. Content that is unconfirmed and must not be supplemented arbitrarily.

For activity screenshots, the appearance of an activity topic ≠ Customer meets the redemption qualification. Whether qualified should be determined by the actual activity rules and complete evidence within the AI skill.

If the issue occurs at the task input stage, priority should be given to ensuring the Main Agent correctly identifies and passes information, rather than repeatedly emphasizing “do not misjudge” in the Sub Agent.

The Main Agent should provide sufficiently correct information and should not provide action-oriented guidance. The AI skill is what truly uses this information and decides the next step.

4. Case 2: The Sub Agent’s reply was correct, but the final reply changed

Actual logs may show intermediate results like this:

{
  "task_responses": {
    "Renovating_response": "Which stage of renovation is your home at now?",
    "UserQuestionFollowup_response": "Yes, just send the cabinet blueprints with dimensions. The planner will help you plan internal storage first, and you can also check dimensions with the cabinet provider in advance to reduce later changes."
  },
  "final_response": "Yes, just send the cabinet blueprints with dimensions.\n\nWhich stage of renovation is your home at now?"
}

As can be seen, the Main Agent merged the two task outputs and simultaneously removed some explanations.

Merging, deduplication, and moderate simplification are not necessarily wrong in themselves. What really needs attention is: Did the Main Agent change key meanings, miss mandatory information, or arbitrarily modify fixed original text, prices, rules, or promises?

If the task output was already correct, but the final reply has obvious deviations, you should not only modify the Sub Agent’s skill but also clearly define the boundaries for handling the final reply in Conditional Adherence, for example:

When integrating subtask outputs, duplicate expressions can be removed, but confirmed key facts, necessary conditions, and business conclusions must be retained.
Content marked as mandatory for original sending must not be rewritten; Business facts not provided by subtasks must not be supplemented out of thin air.

Also check task_responses and final_response to determine exactly at which step the content changed.

5. What should be written in each of the four prompt configuration positions?

Where a rule is written determines who sees it, when it takes effect, and which stage it affects.

Configuration Position Main Role in the System Described Here Suggested Content to Include Suggested Content to Exclude
Role Business background shared by Main and Sub Agents Customer service identity, service target, product positioning, overall business goals Overly detailed branch processes, complex invocation conditions
Communication Style General constraints shared by Main and Sub Agents Reply tone, global logic constraints, expression norms, necessary common terminology explanations, global understanding content Complex business judgments applicable only to a specific skill
Conditional Adherence Primarily constrains the Main Agent Skill trigger conditions, task input organization, final output integration, concepts the Main Agent must understand All business details required only when the Sub Agent executes
AI Skill Primarily constrains the Sub Agent executing this skill Specific scenario judgments, processing steps, tool invocations, reply rules Global personas unrelated to this skill or processes of other skills

The above “who sees it” refers to the configuration method in the original system case and is not a general technical guarantee for all multi-Agent products.

1. Role: Let the Agent know who it is and what business it is handling

The Role is used to provide a stable business background, ensuring the Main and Sub Agents have a common understanding of the service scenario.

Writing suggestion: Simply explain the customer service identity, service target, and core business goals. You don’t need to stuff all branch processes into the Role. A more detailed Role does not necessarily mean more accurate task execution.

2. Communication Style: Constrain the commonalities of all replies

Content suitable for this section includes:

  • Replies should be professional, natural, and concise, prioritizing the customer’s current question;

  • Do not fabricate prices, product features, or promises;

  • For terminology that both Main and Sub Agents need to understand, provide short, unified definitions.

For example, if a certain camera model is abbreviated as Luna, but the Agent frequently misinterprets it as a person’s name. In this case, adding a large amount of Luna materials to the knowledge base is useless because Luna is not the focus in this context. If both Main and Sub Agents need to recognize this name, a short explanation can be added:

In the business context, "Luna" refers to a camera model, not a customer's name; When customers inquire about Luna's features, price, or usage, understand it as a product model.

If only the Main Agent’s task inputs frequently misjudge, it can also be prioritized in “Conditional Adherence”; Do not stuff the same long rule into multiple places just for safety.

3. Conditional Adherence: Focus on managing Main Agent’s understanding, distribution, and integration

This part primarily handles three things:

  • When to trigger what task: Clearly define trigger conditions for each AI skill to avoid selecting the wrong subtask.

  • What to pass to subtasks: Ensure task input contains accurate customer intent, key context, and necessary unconfirmed information.

  • How to handle task output: Restrict inappropriate rewriting, omissions, or overwriting, and clearly define necessary original text retention requirements.

Taking “Customer sends a screenshot with a topic” as an example, the Main Agent definitely cannot by default understand that “#SweatSpace” is sharing a topic, so first determine how the Main Agent should understand this image.

Can be written as:

When customers send screenshots, identify the topics, text, and related business information actually visible in the image; Distinguish between confirmed content and unconfirmable content.
Pass valid information relevant to the current business into the task input. Do not directly determine that the customer has completed the activity or qualifies for redemption just because a brand name or activity topic appears.

If a customer sends multiple screenshots at once or supplements evidence over multiple turns, the Main Agent should also retain previously identified information to avoid re-judging based only on the latest screenshot.

With correct configuration, more explicit image information and customer intent judgments can be observed in the task input.

Note: The Main Agent’s task input should accurately describe facts and missing information; Whether the activity conditions are actually met still needs to be judged by the skill responsible for activity processing according to the rules.

4. AI Skill: Clearly write the execution logic for specific scenarios

The AI skill is responsible for handling the corresponding task and is suitable for carrying specific business logic, for example:

  • Under what conditions to execute a specific branch;

  • When to call the knowledge base or other tools, and which parameters to pass when calling;

  • What to do if the query fails or conditions are not met;

  • What final reply to generate, whether fixed original text must be used.

The most important thing here is to distinguish between trigger conditions and execution conditions. For example, “Customer replies 1” cannot solely represent the customer choosing an option; It must be combined with the specific question previously asked to decide whether to execute subsequent operations.

6. Six Principles for Writing Prompts

  1. Find the problem first, then add constraints. Do not directly add restrictions to all configurations without locating which layer went wrong.

  2. Write rules in the stage that is truly responsible for execution. For Main Agent intent understanding and task distribution issues, prioritize modifying “Conditional Adherence”; For Subtask business processing issues, prioritize modifying the corresponding “AI Skill”.

  3. Provide correct practices, not just prohibitions. For example, rather than “Prohibit misjudging screenshots with topics,” it is more effective to write “First identify visible topics, retain confirmed conditions, do not judge as qualified when unconfirmable.”

  4. Try to keep the same rule assigned to only one clear place. Repeating long constraints across multiple configurations can easily lead to conflicts and increases maintenance costs.

  5. Rules must be bound to real business context. Do not rely solely on isolated keywords or numbers; The customer’s current expression, the previous turn’s question, and historical information often jointly determine the meaning.

  6. Distinguish between internal execution instructions and customer-facing scripts. Prompts can specify which skills or tools to invoke, but it is not recommended to write internal process descriptions like “Which skill handles the reception” or “Main Agent has handed the task to the Sub Agent.”

The following are counter-examples shown in the original text. The main issues are mixed responsibilities, redundant constraints, or placing subtask processing logic in inappropriate positions. Troubleshooting should be combined with actual logs, not just looking at whether it is superficially written in the prompts.

7. Recommended Troubleshooting Process

When an incorrect reply occurs online, you can review it in the following order:

  1. Verify the customer’s original message: Are there images, consecutive multiple messages, contextual references, or previously confirmed conditions?

  2. Check the task input: Did the Main Agent lose information, make erroneous inferences, or misread terminology?

  3. Check the invoked AI skill: Was the actually invoked skill supposed to handle this scenario?

  4. Check skill output and tool results: Determine if the error stems from business logic, tool returns, or knowledge base retrieval.

  5. Compare the final reply: Did the Main Agent incorrectly change, delete, or merge the correct task output?

  6. Only modify the prompt at the corresponding layer, then regression test with the original case. Also test similar but non-triggering scenarios to prevent fixing one issue while introducing a new misjudgment.

8. Conclusion

Writing good AI customer service prompts is not about making the restrictions longer and longer, but about clearly distinguishing who is responsible for understanding, who is responsible for execution, who is responsible for integration, and where to modify when errors occur.

  • Role is responsible for stating identity and business background.

  • Communication Style is responsible for global expression requirements and necessary shared cognition.

  • Conditional Adherence is responsible for the Main Agent’s understanding, task distribution, and final result integration.

  • AI Skill is responsible for business judgment, tool operations, and reply logic for specific tasks.

When every rule has clear responsibility boundaries, prompts become more concise, and AI behavior becomes easier to explain, test, and maintain.