Building a Context-Aware AI Agent
The operational pipeline for turning a general LLM into a trustworthy, business-specific agent.
- Difficulty
- Advanced
- Time to result
- ~months to results
- Steps
- 6
- Confidence
- 85%
Turning a general-purpose LLM into a trustworthy, business-specific agent requires more than a clever prompt. Des Traynor walks through the operational pipeline Intercom built for Fin, its AI support agent, which underpins how it stays accurate, on-brand, and safely scoped to a single business's knowledge. The framework moves from constraining the model's domain, through extracting real user intent, retrieving grounded knowledge via vector search across every available source (docs, past conversations, API references), synthesizing a defensible answer, and finally matching tone to the brand. Continuous benchmarking against nuanced, multi-part queries - not just obvious FAQ-style questions - is what separates a genuinely useful agent from a superficial wrapper around a foundation model.
Origin
Built by Intercom's team in the weeks after ChatGPT's release, then hardened once GPT-4 access allowed tighter constraints and lower hallucination rates.
Core principles
- 01Constrain scope before you optimize capability
- 02Ground every answer in retrieved company-specific knowledge
- 03The quality of the knowledge source is the single biggest performance variable
- 04Benchmark on nuanced edge cases, not obvious FAQ answers
How to run it
- 1
Constrain the Domain
Explicitly stop the agent from answering anything outside the business's scope (e.g., refuse to discuss politics or competitors) to prevent it from being steered off-brand.
Watch out Without hard guardrails, users will find slippery-slope prompts that push the bot into opinions the company never wants to state.
- 2
Extract Real Intent
Parse the user's message, however messy or multi-part, to identify the actual question(s) being asked before searching for an answer.
- 3
Vector Search Every Knowledge Source
Run vector search across the public knowledge base, the ongoing conversation thread, product docs, and even API documentation to assemble the relevant context.
Pro tip The richness of what you feed the agent - not the model choice - is usually what separates a great instance from a weak one.
- 4
Synthesize a Grounded Answer
Combine the retrieved context into a single answer while using tight prompting to curtail hallucinations and prevent the model from inventing information to please the user.
- 5
Match Brand Tone
Package the answer so it sounds appropriate for the specific business, whether that's a bank or a surf shop, rather than a generic assistant voice.
- 6
Benchmark on Nuance, Not Obvious Questions
Test with multi-step, edge-case queries; simple FAQ answers make competing bots look identical, but nuanced tests reveal real quality gaps.
Watch out If you only test with obvious questions, you'll wrongly conclude all GPT-wrapper bots are the same.
In the wild
Intercom built Fin on top of GPT-4, constraining it to stay on-topic, grounding its answers via vector search across knowledge bases and past conversations, and packaging responses in the customer's brand voice.
→ Customers running Fin saw support volume drop by 15-50%, with the bot successfully resolving multi-part, nested questions end-to-end.
A legal tech team builds an assistant constrained to only answer questions using a firm's own case files and precedent library, using vector search to retrieve relevant clauses before generating a grounded summary in the firm's formal tone.
→ Associates get faster first-pass research while the firm avoids the reputational risk of the model inventing case law.
Common mistakes
Testing only obvious questions
Many competitors look identical when tested with simple queries; nuance is what actually separates strong and weak agents.
Not curtailing hallucinations
Failing to constrain the model leads it to fabricate answers in an attempt to please the user.
Is it for you?
Best for
Teams building a business-specific AI agent on top of a foundation model like GPT-4
Not ideal for
Simple one-off content generation tasks that don't require grounding in proprietary data
From the transcript
“Getting the bot despite all its infinite wisdom to refuse to engage in topics that are anything other than this bank or this surf shop…”
“So you have to perform a search of given that this is the question, drinking in all of this context, what do we suppose is…”
“The vector search is really important. The knowledge sources are the single biggest variant.”
From the episode
Des Traynor - Real Talk about AI and Software - [Invest Like the Best, EP.340]