Example code showing how to use Kapa.ai as a tool in an agentic system with LangGraph.
📖 Read the blog post for the full context and walkthrough.
agentic-kapa.mp4
This is example code to illustrate the concepts from our blog post — it's not meant to be run as-is. Think of it as a reference implementation to help you build your own agentic workflows with Kapa.
The example shows a support agent that:
- Uses Claude to analyze user intent and make routing decisions
- Queries Kapa for accurate documentation-based answers
- Creates support tickets when docs aren't sufficient
- Evaluates response quality and decides next actions
If you're thinking about building something similar, here are some patterns that might be helpful:
- Reasoning layer (
reasonernode): LLM makes all the decisions - Tool nodes: Pure execution functions — just call APIs and return results
- Kapa as a tool: Returns structured responses with sources and uncertainty flags
User Question → Reasoning Agent (analyzes intent)
↓
Technical? → Query Kapa → Reasoning Agent (evaluates quality)
↓ ↓
Support? → Create Ticket Good answer? → Deliver to user
↓
Uncertain? → Offer ticket creation- Kapa responses include an
is_uncertainflag that helps the agent decide whether to escalate - Support tickets can include full context (what the user asked, what Kapa returned, why it wasn't sufficient)
- LangGraph's
tools_conditionhandles the routing between reasoning and tools - The system prompt is just a simple policy, not complex instructions
Kapa focuses on being really good at answering questions from your docs. Your agent handles everything else — your specific business logic, escalation rules, and integrations. This way you get accurate technical answers without having to build your own RAG pipeline.
Check out the blog post for more details and reasoning behind this approach.