Skip to content

Pet Clinic agents are telling users to buy pet products we don't actually offer #275

Description

@liustve

Hi @awsapm can you look into this?

ROOT CAUSE ANALYSIS

Critical Issue: Data Availability Problem in nutrition-service-nodejs

Error Rate: 7% average (up to 18% peak) over the last 24 hours
HTTP Status: 404 Not Found errors
Affected Operation: GET /nutrition/:pet_type

Telemetry Evidence:

  1. Service Dependency Chain:

    • pet_clinic_agent.DEFAULT (Primary chatbot) →
    • nutrition_agent.DEFAULT (Nutrition specialist) →
    • nutrition-service-nodejs (Product database) →
    • MongoDB (test|mongodb|27017)
  2. Error Pattern from Transaction Search (100% sampled data):

    • 3,279 error requests with HTTP 404 status in the last 24 hours
    • MongoDB findOne operations complete successfully (OK status)
    • But the service returns 404, indicating missing data in the database
  3. Performance Impact:

    • Successful requests: 43,374 (93% success rate)
    • Failed requests: 3,279 (7% error rate)
    • When data is missing, the chatbot likely falls back to generic or hallucinated recommendations

Why This Causes Incorrect Product Recommendations:

When the nutrition agent queries for specific pet types and receives 404 errors:

  1. The MongoDB query executes successfully but returns no matching records
  2. The service returns HTTP 404 (Not Found)
  3. The Bedrock agent (Claude 3.5 Haiku model) doesn't receive product data
  4. The LLM fills the gap with generic nutritional advice or hallucinates product names
  5. Users see recommendations for products that don't exist in your inventory

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

OPERATIONAL RECOMMENDATIONS

Immediate Actions:

  1. Audit MongoDB Product Database

    • Connect to MongoDB instance: test|mongodb|27017
    • Verify nutrition product records exist for all supported pet types
    • Check for missing or incomplete product catalog entries
    • Validate pet_type field values match what the chatbot queries
  2. Review Data Synchronization

    • Ensure product catalog is properly loaded into MongoDB
    • Check if there's a data migration or seeding process that failed
    • Verify environment-specific configuration (currently using "test" database)
  3. Implement Fallback Handling

    • Configure the nutrition agent to explicitly handle 404 responses
    • Add guardrails to prevent hallucinated product recommendations
    • Return "product not available" messages instead of making up products

Monitoring Improvements:

  1. Create SLO for Data Availability

    • Set up an SLO monitoring the error rate for GET /nutrition/:pet_type
    • Target: < 1% error rate (currently at 7%)
    • Alert when 404 errors exceed threshold
  2. Add Custom Metrics

    • Track which pet_type values are causing 404s
    • Monitor MongoDB query success vs. empty result sets
    • Create dashboards showing product catalog completeness
  3. Enhanced Logging

    • Log the specific pet_type being queried when 404 occurs
    • Capture which products the LLM recommends vs. what's in inventory
    • Track user feedback on incorrect recommendations

Configuration Adjustments:

  1. Bedrock Agent Prompt Engineering

    • Update the nutrition agent's system prompt to:
      • Only recommend products from the provided API response
      • Explicitly state when product information is unavailable
      • Never invent or hallucinate product names
  2. API Response Handling

    • Modify nutrition-service-nodejs to return structured error messages
    • Include available pet types in error responses
    • Provide fallback product categories when specific items are missing

Infrastructure Considerations:

  1. Database Environment Review

    • Currently using "test" MongoDB database - verify this is intentional for production
    • Consider separate databases for dev/test/prod environments
    • Implement database health checks and data validation
  2. Service Resilience

    • Add circuit breaker pattern for MongoDB connection failures
    • Implement caching for frequently requested nutrition data
    • Consider read replicas if database performance becomes an issue

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

SUMMARY

The chatbot is recommending non-existent products because 7% of nutrition queries return 404 errors due to missing data in MongoDB. The Bedrock LLM, lacking actual product information,
generates plausible-sounding but incorrect recommendations. Fix this by populating the MongoDB product catalog, adding proper error handling, and implementing guardrails to prevent
hallucinated responses.

Priority: HIGH - This directly impacts customer trust and could lead to order fulfillment issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions