XML Tags in Prompting

XML tags provide structure to your prompts, helping the AI model focus on specific sections and follow instructions more precisely. They're a powerful tool for organizing your prompt content and enhancing prompt effectiveness.

What are XML Tags in Prompting?

XML tags are markup elements used to structure your prompts. They consist of:

  • An opening tag: <tag_name>
  • Content between the tags
  • A closing tag: </tag_name>

For example: <greeting>Hello, how can I help you today?</greeting>

Why Use XML Tags?

XML tags help:

  • Organize prompt content logically
  • Draw the AI's attention to specific instructions
  • Separate different types of information
  • Create clear boundaries between sections
  • Improve prompt effectiveness and consistency

How to Implement XML Tags in Your Prompts

  1. Identify distinct sections or types of information in your prompt
  2. Create meaningful tag names that reflect the purpose of each section
  3. Wrap each section in opening and closing tags (<tag_name> and </tag_name>)
  4. Ensure tags are properly nested if you're using hierarchical structure
  5. Check that all tags are properly closed

How to Use XML Tags at the Supervisor Level

  1. In your supervisor prompt, identify different routing conditions or flows
  2. Create XML tags for each condition (e.g., <normal_flow>, <technical_flow>)
  3. Within each tag, clearly describe when that particular flow should be activated
  4. Specify which agent should handle each flow
  5. Save your changes and test different conversation paths

Example:

<normal_flow>
For normal conversational interactions, use the Coach agent.
</normal_flow>

<technical_flow>
If the user asks technical questions about programming, databases, or system architecture, use the TechExpert agent.
</technical_flow>

How to Use XML Tags at the Agent Level

  1. In your agent prompt, identify distinct types of responses or procedures
  2. Create XML tags for each type (e.g., <greeting>, <prayer_deep_dive>)
  3. Within each tag, detail the specific questions, steps, or responses for that type
  4. Use nested tags if you have sub-categories within a procedure
  5. Test your agent with inputs that should trigger each response type

Example:

<prayer_deep_dive>
1. Ask the user about their current prayer routine
2. Explore challenges they're facing with prayer
3. Discuss their goals for improving their prayer life
4. Provide specific techniques based on their responses
5. Suggest a personalized prayer plan
</prayer_deep_dive>

<rage_deep_dive>
1. Ask the user about situations that trigger their anger
2. Explore physical and emotional responses they experience
3. Discuss impact of anger on their relationships
4. Provide specific anger management techniques
5. Create a personalized plan for managing rage
</rage_deep_dive>

Common XML Tag Use Cases

Sectioning Agent Knowledge

<product_knowledge>
Product XYZ is a cloud-based solution that offers scalable processing for enterprise data.
Key features include real-time analytics, secure data storage, and API integration.
</product_knowledge>

<troubleshooting>
Common issues include connection problems, slow performance, and data import errors.
</troubleshooting>

Defining Response Types

<informational_response>
When providing information, be concise and factual. Include relevant statistics when available.
</informational_response>

<emotional_support>
When providing emotional support, use empathetic language and validate user feelings.
</emotional_support>

Structuring Procedures

<onboarding_procedure>
1. Welcome the user and thank them for choosing our service
2. Explain the key benefits they'll receive
3. Collect necessary information for account setup
4. Guide them through their first action
5. Offer additional resources and next steps
</onboarding_procedure>

Best Practices for Using XML Tags

  1. Choose descriptive tag names that reflect content purpose
  2. Keep tag naming consistent across all your prompts
  3. Close all tags properly to avoid parsing issues
  4. Nest tags logically when representing hierarchical information
  5. Use tags to separate distinct conversation flows or procedures
  6. Don't overuse tags—only create them for meaningful separations

Next Steps

Now that you understand how to use XML tags, learn about supervisor-agent interaction to ensure your system works cohesively.