Feedback Engine
Query feedback loop, accuracy analysis, and improvement suggestions
The feedback engine collects ratings on query results and uses them to improve accuracy over time. It is the self-improving loop that makes Epistom better with use — good queries get promoted to verified status, bad patterns get flagged for review.
How It Works
Submitting Feedback (feedback_engine.py)
The Feedback dataclass captures a rating for a specific query:
Feedback is persisted to the query_feedback PostgreSQL table with the query ID, rating, optional comment, and timestamp.
Analyzing Feedback
The analyze_feedback() function reviews recent feedback history and generates ImprovementSuggestion objects:
Feedback Classifier (feedback_classifier.py)
Classifies feedback patterns to identify systemic issues:
- Repeated negative feedback on the same concept suggests a definition problem
- Negative feedback on a specific join path suggests a schema mapping issue
- Consistently positive feedback qualifies queries for verified query promotion
Feedback Analyzer (feedback_analyzer.py)
Aggregates feedback into actionable insights:
- Accuracy rate by concept domain
- Most common failure patterns
- Trending positive/negative query categories
VQ Promotion on Feedback
The check_vq_promotion_on_feedback() function evaluates whether a query should be promoted to verified status based on its feedback history. A query needs consistent positive ratings above a threshold with no recent negative feedback.
Architecture
The feedback loop:
- Agent calls
ask_questionand receives results with aquery_id - Agent (or human) calls
report_feedbackwith thequery_idand a rating - Feedback is stored in PostgreSQL
- Periodic analysis runs
analyze_feedback()to generate improvement suggestions - Suggestions are surfaced to data stewards for review
- Approved improvements update the knowledge model or promote verified queries
API / Usage
REST API endpoints:
MCP tool:
Accuracy Metrics
The get_accuracy_metrics() function returns aggregate statistics:
- Total queries in period
- Correct/wrong/partial breakdown
- Accuracy rate (correct / total)
- Trend over time (improving or degrading)
Technical Details
- Feedback is workspace-isolated in multi-tenant deployments
- The feedback database is initialized lazily on first submission (
_init_feedback_db()) - Feedback history queries support configurable time windows (default 30 days)
- Humans always approve changes — the system generates suggestions but never auto-modifies the knowledge model