iconsulting/packages/services/conversation-service/src/infrastructure/claude
hailin ae99b78579 fix(conversation): track token usage and message count in conversation entity
Problem:
- Token usage was recorded to token_usage table but not to conversation entity
- Message count was not being incremented
- Dashboard showed 0 tokens for all conversations

Solution:
- Add inputTokens/outputTokens fields to StreamChunk interface
- Return token usage in 'end' chunk from ClaudeAgentServiceV2
- Capture token usage in conversation.service.ts sendMessage
- Call conversation.addTokens() and incrementMessageCount() after each exchange
- Consolidate conversation updates into single repo.update() call

Files changed:
- claude-agent-v2.service.ts: Add token fields to StreamChunk, return in 'end'
- conversation.service.ts: Track tokens and message counts properly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 17:08:23 -08:00
..
prompts feat(agent): implement 3-layer architecture for better response quality 2026-01-23 07:51:19 -08:00
strategy feat(agent): implement consulting strategy engine with V2 agent service 2026-01-24 06:32:07 -08:00
tools feat(agent): add 4 real-time tools for enhanced agent capabilities 2026-01-23 00:46:55 -08:00
claude-agent-v2.service.ts fix(conversation): track token usage and message count in conversation entity 2026-01-25 17:08:23 -08:00
claude-agent.service.ts fix(conversation): resolve TypeScript type errors in token tracking 2026-01-23 08:27:03 -08:00
claude.module.ts refactor(services): implement 4-layer Clean Architecture for all backend services 2026-01-24 22:18:22 -08:00
intent-classifier.ts feat(agent): implement 3-layer architecture for better response quality 2026-01-23 07:51:19 -08:00
response-gate.ts feat(agent): implement 3-layer architecture for better response quality 2026-01-23 07:51:19 -08:00
token-usage.service.ts refactor(services): implement 4-layer Clean Architecture for all backend services 2026-01-24 22:18:22 -08:00