AI Embeddings Flow - Checklist

Step-by-step checklist to get embeddings flowing into MongoDB

AI Embeddings Flow - Checklist

You have 0 embeddings but all the infrastructure is set up. Here's what to check:

✅ What's Already Working

📋 Checklist to Get Embeddings

1. Check OpenAI API Key ⚠️ CRITICAL

# In your .env file (backend)
OPENAI_API_KEY=sk-...

# Verify it's loaded
# Check backend logs on startup for embedding config

Without this, embeddings CANNOT be generated even if decisions are logged.

2. Verify Frontend Learning Is Active

Open browser console and look for:

🧠 Platform Learning: Created new task <task-id>
🧠 Platform Learning: Created session <session-id>

If you see errors, check:

3. Trigger AI Decisions

The learning system only logs when AI features are used. Try:

Option A: Use AI Chat

Option B: Use Vibe Coding

Option C: Manual Test Decision

// In browser console
const learning = /* inject AgentPlatformLearningService somehow */;
await learning.logDecision({
  source: 'manual-test',
  type: 'implementation-choice',
  question: 'Test decision',
  options: ['A', 'B', 'C'],
  chosen: 'B',
  reasoning: 'Testing embedding generation',
  confidence: 0.85
});

4. Check Backend Logs

Look for these SUCCESS indicators:

✅ MongoDB Atlas Vector Search is available
[AgentVectorMemoryService] Stored embedding: <id>
[EmbeddingService] Generated embedding (1536 dimensions)
📊 Vector stats retrieved: 1 embeddings  ← SUCCESS!

Look for these ERROR indicators:

⚠️ Failed to generate embedding: No API key
⚠️ MongoDB Atlas Vector Search not available
❌ Failed to store embedding

5. Verify Task Creation

Check MongoDB directly:

// In MongoDB Compass or Shell
use ai-agents

// Should see tasks
db.agent_tasks.find().pretty()

// Should see decisions
db.agent_decisions.find().pretty()

// Should see embeddings (if OpenAI key works)
db.agent_embeddings.find().limit(5).pretty()

🎯 Expected Flow

When everything works:

  1. User triggers AI feature (chat, vibe coding, etc.)
  2. Frontend: AgentPlatformLearningService.logDecision() queues decision
  3. Frontend: Batch flush sends to backend /api/ai-agents/tasks/:taskId/sessions/:sessionId/decisions
  4. Backend: AgentTaskService stores decision in agent_decisions
  5. Backend: AgentVectorMemoryService generates embedding via OpenAI
  6. Backend: Stores embedding in agent_embeddings collection
  7. Backend logs: 📊 Vector stats retrieved: 1 embeddings

🐛 Troubleshooting

"Still showing 0 embeddings after triggering AI features"

Check in order:

  1. Frontend Console: Are decisions being logged?

    🧠 Platform Learning: Logged decision <id>
    
  2. Network Tab: Is POST to /api/ai-agents/tasks/.../decisions succeeding?

    • If 404: Task/session not created properly
    • If 401: Auth issue (but these are public endpoints)
    • If 500: Check backend logs
  3. Backend Logs: Is embedding generation working?

    • Look for [EmbeddingService] logs
    • Check for OpenAI API errors
  4. MongoDB: Are decisions being stored?

    • Check agent_decisions collection
    • If yes but no embeddings → OpenAI key issue
    • If no → Backend not receiving requests

"Frontend not creating task/session"

// Check localStorage
localStorage.getItem('platform-learning-task-id')
localStorage.getItem('platform-learning-session-id')

// If null, service didn't initialize
// Check console for errors during app startup

🚀 Quick Test Script

Create this test endpoint in backend to manually trigger embedding:

// apis/backend-api/src/app/ai-agents/ai-agents-public.controller.ts

@Post('test/embedding')
async testEmbedding(): Promise<any> {
  const testDecision = {
    type: 'test',
    question: 'Is this working?',
    chosen: 'yes',
    reasoning: 'Testing embeddings',
    confidence: 0.9,
  };
  
  const result = await this.vectorMemory.storeDecisionWithEmbedding(
    'test-task-id',
    'test-session-id',
    testDecision
  );
  
  return { success: true, embeddingId: result };
}

Then call: POST http://localhost:3000/api/ai-agents/test/embedding

If this works → Frontend issue
If this fails → Backend/OpenAI key issue


Created: December 10, 2025
Session: 13
Next Steps:

  1. Verify OPENAI_API_KEY in .env
  2. Try triggering AI feature
  3. Check backend logs for embedding generation
  4. Report back what you see!