Commit Graph

1 Commits

Author SHA1 Message Date
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