My AI sales agent keeps derailing. Ask it for a weekly MQL report or campaign attribution, and it starts suggesting database index optimizations and query caching.
The problem is the grounding. The agent's knowledge base is a generic mix of system admin docs and our marketing playbooks. When it sees "metrics" and "data," it defaults to the technical context, not the business one.
Here's the fix that worked:
1. **System Prompt Addition:** Added a strict instruction: "When the user asks for marketing, sales, or funnel metrics, interpret 'database' as the CRM (Salesforce) and/or Marketing Automation (HubSpot) platform. Do not make infrastructure or optimization suggestions unless the query contains the words 'server,' 'latency,' or 'postgres.'"
2. **Contextual Few-Shot Examples:** In the RAG pipeline, I prepended two clear examples to the retrieved context:
* **Query:** "Show lead source performance this quarter." **Correct Response:** "Pulling MQL conversion rates by source from HubSpot." **Incorrect Response:** "Consider optimizing your lead_source table indexes."
* **Query:** "Why is the sales pipeline slowing down?" **Correct Response:** "Analyzing stage duration in Salesforce." **Incorrect Response:** "Database workload may be high. Check slow query logs."
The derailments stopped. The agent now correctly routes metric requests to the BI tool API calls for our CRM/MA platforms. It's about forcing the semantic boundary.