iconsulting/packages/services
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
..
conversation-service feat(agent): implement 3-layer architecture for better response quality 2026-01-23 07:51:19 -08:00
evolution-service fix(schema): sync ORM entities with database schema 2026-01-23 05:00:38 -08:00
file-service fix(file-service): specify explicit column types for TypeORM entities 2026-01-10 06:05:36 -08:00
knowledge-service fix(knowledge): add pgvector transformer for TypeORM embedding columns 2026-01-23 07:12:28 -08:00
payment-service fix(payment): use PORT env variable instead of PAYMENT_SERVICE_PORT 2026-01-10 02:48:44 -08:00
user-service fix(health): exclude /health endpoint from API prefix 2026-01-10 02:30:24 -08:00