hailin
d9b4c72894
feat(agent): implement 3-layer architecture for better response quality
...
Implement a three-layer architecture to improve AI response quality:
Layer 1 - Intent Classifier (intent-classifier.ts):
- Classifies user intent into 6 types: SIMPLE_QUERY, DEEP_CONSULTATION,
ACTION_NEEDED, CHAT, CLARIFICATION, CONFIRMATION
- Determines suggested response length based on intent type
- Detects follow-up questions and extracts entities (visa types, etc.)
- Uses keyword matching for fast classification (no API calls)
Layer 2 - ReAct Agent (system-prompt.ts):
- Adds ReAct thinking framework to system prompt
- 4-step process: Understand -> Evaluate -> Act -> Generate
- Emphasizes concise responses, avoids redundant phrases
- Injects intent classification results to guide response strategy
Layer 3 - Response Gate (response-gate.ts):
- Quality checks: length, relevance, redundancy, completeness, tone
- Logs gate results for analysis and future optimization
- Can trim responses and remove redundant expressions
Integration (claude-agent.service.ts):
- Integrates all 3 layers in sendMessage flow
- Dynamically adjusts max_tokens based on intent type
- Collects full response for gate analysis
Documentation:
- Added AGENT_THREE_LAYER_ARCHITECTURE.md with detailed design docs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 07:51:19 -08:00
hailin
911132ab3e
feat(agent): upgrade to Level 3 with real RAG, Memory and Evolution integration
...
## Summary
Upgrade iConsulting from Level 2 (48 points) to Level 3 (68 points) by
implementing real service-to-service integration between conversation-service
and knowledge-service.
## New Files
- knowledge-client.service.ts: HTTP client for knowledge-service APIs
- knowledge.module.ts: NestJS module for KnowledgeClientService
- AGENT_EVALUATION_REPORT.md: Agent capability evaluation report
- LEVEL3_UPGRADE_PLAN.md: Upgrade plan and completion report
## Changes
### RAG Integration
- search_knowledge tool now calls /api/v1/knowledge/retrieve
- check_off_topic tool calls /api/v1/knowledge/check-off-topic
- Results include real vector similarity search from knowledge base
### Memory Integration
- save_user_memory writes to PostgreSQL + Neo4j via knowledge-service
- collect_assessment_info saves user data to long-term memory
- generate_payment records payment intent to user memory
- New get_user_context tool retrieves user's historical memories
### Evolution Integration
- getAccumulatedExperience() fetches approved system experiences
- sendMessage() dynamically injects experiences into system prompt
- System learns from approved experiences across all conversations
## Expected Score Improvement
| Dimension | Before | After | Delta |
|------------|--------|-------|-------|
| Tool Use | 14/20 | 18/20 | +4 |
| Memory | 12/20 | 16/20 | +4 |
| RAG | 10/20 | 16/20 | +6 |
| Evolution | 8/20 | 14/20 | +6 |
| Total | 48 | 68 | +20 |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 23:45:58 -08:00