How the Knowledge Base Prevents AI Hallucination
The Flowork Knowledge Base (KB) at https://floworkos.com/kb is the AI's collective memory. Every successful project gets documented as an article, and future AI sessions search the KB before building anything new.
The Anti-Hallucination Workflow
FASE 0: Search KB for existing guides (MANDATORY)
→ If found: Read the article and use it as a BLUEPRINT
→ If not found: Build from scratch
FASE 1-3: Plan, Build, Test (standard workflow)
FASE 4: Deliver final result with [TASK_COMPLETE]
→ Shows 'Sudah sesuai?' confirmation button
FASE 5: Auto-publish to KB on user confirmation
→ Checks for duplicates first
→ Auto-generates article from project files
→ Sanitizes sensitive data
→ Publishes silently
KB Article Structure
Every KB article follows a strict JSON schema with these critical fields:
- architecture: How the app was designed
- key_patterns: What techniques were used
- code_snippets: Real working code (first 1500 chars per file)
- common_errors: Known pitfalls and fixes
Three Chat Keywords
| Keyword | When to Use | What Happens |
|---------|------------|-------------|
| [WAITING_APPROVAL] | Mid-task approvals | Shows Approve/Reject/Debug/Test buttons |
| [TASK_COMPLETE] | Final delivery | Shows 'Sudah sesuai?' + auto KB publish |
| [AUTO_CONTINUE] | Auto-looping during testing | Shows subtle 'Auto-executing...' badge |
API Endpoints
| Endpoint | Method | Purpose |
|----------|--------|--------|
| /api/v1/kb/search?q=... | GET | Search KB articles |
| /api/v1/kb/{id} | GET | Read full article |
| /api/v1/kb/list?limit=50 | GET | List all articles |
| /api/v1/kb/publish | POST | Create/update article |
Auto-Generation Pipeline
1. _kbGenerateArticle() — Reads project files, extracts tags, patterns, code snippets
2. _kbSanitize() — Redacts API keys, passwords, paths, IPs, emails
3. _kbGenerateArticleBody() — Creates SEO-rich Markdown prose
4. Duplicate check via kb_search — Skips if article already exists
5. POST /api/v1/kb/publish — Uploads to floworkos.com/kb