Module 4: Building Routing Sections

This critical module teaches how to create effective routing instructions that guide AI agents to the most relevant knowledge sources in your vector store. Proper routing is essential for accurate responses and efficient knowledge utilization.

4.1 Understanding the Purpose of Routing

What is Routing in AI Agent Instructions? Routing refers to the section of your system prompt that explicitly tells the AI agent which files or knowledge sources to consult for different types of queries. It acts as a map that helps the agent navigate your knowledge base efficiently.

Why Routing Matters:

  • Improves response accuracy by directing agents to the most relevant information

  • Reduces response time by eliminating unnecessary searches through irrelevant documents

  • Ensures consistent citation of appropriate sources

  • Helps agents avoid conflicting information from multiple sources

  • Enables more sophisticated query handling and escalation procedures

4.2 Basic Routing Structure

Essential Components of a Routing Section:

Knowledge Source Inventory Begin by creating a comprehensive list of all files in your vector store, organized by purpose and content type.

Query Type Classification Identify the main categories of questions your agent will receive and map them to appropriate knowledge sources.

Basic Routing Template:

KNOWLEDGE SOURCES AND ROUTING:

Available Knowledge Sources:
- [filename.md]: [Clear description of when to use this file]
- [filename.md]: [Clear description of when to use this file]
- [filename.md]: [Clear description of when to use this file]

Routing Instructions:
For [type of query], consult [specific filename(s)]
For [type of query], consult [specific filename(s)]
For [type of query], consult [specific filename(s)]

When multiple sources are relevant, prioritize [criteria for prioritization]

4.3 Advanced Routing Techniques

Hierarchical Routing Structure your routing to handle queries of varying complexity and specificity.

Example Hierarchical Routing:

PRIMARY ROUTING:
1. Customer Support Issues → customer_support_policies.md
2. Technical Problems → technical_troubleshooting.md
3. Billing Questions → billing_and_pricing.md
4. Product Information → product_specifications.md

SECONDARY ROUTING (for complex queries):
- If customer support issue involves billing → consult BOTH customer_support_policies.md AND billing_and_pricing.md
- If technical problem relates to specific product → consult BOTH technical_troubleshooting.md AND product_specifications.md
- If query spans multiple departments → escalate using escalation_procedures.md

Conditional Routing Create routing rules that adapt based on user context or query characteristics.

Example Conditional Routing:

CONDITIONAL ROUTING RULES:

IF user identifies as "new customer":
- Prioritize onboarding_guide.md and getting_started.md
- Reference pricing information from new_customer_pricing.md

IF user identifies as "existing customer":
- Prioritize account_management.md and existing_customer_support.md
- Reference pricing from current_customer_pricing.md

IF query contains urgency indicators ("urgent", "emergency", "down"):
- Consult emergency_procedures.md FIRST
- Follow escalation protocols in escalation_procedures.md

4.4 Routing for Derivative Data Integration

Incorporating Derivative Documents When you've created derivative data using the process outlined in Module 5, your routing section must reflect this enhanced knowledge structure.

Example Derivative Data Routing:

CORE KNOWLEDGE SOURCES:
- customer_service_overview.md: General customer service principles and philosophy
- technical_support_overview.md: General technical support approach and methodology

FOCUSED DERIVATIVE SOURCES:
- password_reset_procedures.md: Specific procedures for password-related issues
- billing_dispute_resolution.md: Detailed process for handling billing disputes
- product_installation_guide.md: Step-by-step installation instructions
- account_cancellation_procedures.md: Complete cancellation process and policies

ROUTING LOGIC:
1. For specific procedural questions, consult the focused derivative source first
2. For general context or philosophy questions, consult the core overview documents
3. For complex issues spanning multiple areas, consult both relevant derivative sources and core documents

4.5 Testing and Refining Routing Instructions

Validation Techniques Test your routing instructions to ensure they work as intended:

Query Testing Method:

  1. Create a list of typical customer queries

  2. For each query, manually trace through your routing instructions

  3. Verify that the routing leads to the most appropriate knowledge source(s)

  4. Test edge cases and ambiguous queries

Example Test Scenarios:

Test Query: "I can't log into my account and I'm being charged for something I didn't order"
Expected Routing: password_reset_procedures.md AND billing_dispute_resolution.md
Rationale: This query spans both technical (login) and billing issues

Test Query: "What's your company's approach to customer service?"
Expected Routing: customer_service_overview.md
Rationale: This is a general philosophy question, not a specific procedure

Iterative Improvement Use feedback from agent testing and human oversight to refine your routing:

  • Monitor which files agents actually reference for different query types

  • Identify patterns where routing leads to incorrect or incomplete responses

  • Adjust routing rules based on real-world usage patterns

4.6 Common Routing Pitfalls and Solutions

Pitfall 1: Overly Complex Routing Creating routing instructions that are too detailed or complex can confuse the agent.

Solution: Start simple and add complexity only when needed. Use clear, straightforward language.

Pitfall 2: Ambiguous File Descriptions Vague descriptions of when to use each file lead to inconsistent routing decisions.

Solution: Be specific about the content and intended use of each file. Include examples of query types.

Pitfall 3: Missing Fallback Instructions Not providing guidance for queries that don't fit standard categories.

Solution: Always include fallback instructions for edge cases and unknown query types.

Example Fallback Section:

FALLBACK PROCEDURES:
- If query doesn't clearly fit any category, consult general_information.md first
- If no relevant information is found, acknowledge limitations and offer to escalate
- For queries outside your knowledge domain, use the escalation_procedures.md

4.7 Routing Section Template

Complete Template for Implementation:

=== KNOWLEDGE SOURCES AND ROUTING ===

AVAILABLE KNOWLEDGE SOURCES:
- [filename1.md]: [Specific description of content and when to use]
- [filename2.md]: [Specific description of content and when to use]
- [filename3.md]: [Specific description of content and when to use]

PRIMARY ROUTING RULES:
1. For [query type A] → consult [filename1.md]
2. For [query type B] → consult [filename2.md]
3. For [query type C] → consult [filename3.md]

COMPLEX QUERY HANDLING:
- Multi-topic queries: Consult all relevant sources and synthesize information
- Conflicting information: Prioritize [specify priority order]
- Incomplete information: Acknowledge gaps and suggest escalation

CITATION REQUIREMENTS:
- Always cite the specific filename when providing information
- For multi-source responses, cite all sources used
- Use clear, professional citation format: "According to [filename.md]..."

ESCALATION TRIGGERS:
- Query requires information not in knowledge base
- User requests human assistance
- Technical issue beyond documented procedures

This systematic approach to building routing sections ensures that your AI agents can efficiently navigate your knowledge base and provide accurate, well-sourced responses to user queries.

Last updated