Check Lore Consistency
POST /api/agents/lorekeeper/check-consistency
Comprehensive lore consistency check via LoreKeeper agent with full document analysis.
Analyzes document content for lore inconsistencies, character contradictions, timeline conflicts, and cross-document coherence. Supports both ad-hoc content analysis and tracked document validation with detailed per-document and cross-document issue reporting.
Args: request: FastAPI Request object for service injection context request_data: Consistency check request with documents and analysis options
Returns: ConsistencyCheckResponse: Comprehensive consistency analysis with scores, issues, and suggestions
Raises: HTTPException: If service is unavailable or analysis fails
Note: Uses new service registry pattern with clean dependency injection and automatic fallback handling for service unavailability. Extracts content from DocumentContent objects and provides rich contextual analysis with actionable recommendations.
Request Body required
Section titled “Request Body required ”Comprehensive lore consistency check request.
Validates lore consistency across documents with full context support. Accepts document content with optional IDs, paths, and metadata for maximum flexibility and comprehensive analysis.
Fields: documents: List of DocumentContent objects to check (REQUIRED, min 1) project_type: Project type for lore rules (OPTIONAL, default: “worldbuilding”) check_depth: Analysis depth level (OPTIONAL, default: “moderate”) include_suggestions: Include fix suggestions (OPTIONAL, default: True) compare_against_canon: Compare against specific canon (OPTIONAL) cross_reference: Check consistency across all docs (OPTIONAL, default: True)
JSON Example: { “documents”: [ { “content”: “Arasai fought alongside Erebos…”, “document_id”: “doc_123”, “title”: “Chapter 1” } ], “project_type”: “worldbuilding”, “check_depth”: “deep”, “include_suggestions”: true, “cross_reference”: true }
Used By: - POST /api/agents/lorekeeper/check-consistency - Lore consistency validation UI - Document validation workflows
object
Documents to check with full context
Complete document context for lore consistency checking.
Provides rich document context including content, identifiers, and metadata. Supports flexible usage: content-only for ad-hoc analysis OR complete context with IDs, paths, and metadata for tracked documents.
Fields: content: Document content to analyze (REQUIRED) document_id: Source document ID from database (OPTIONAL) path: File path or document location (OPTIONAL) title: Document title for reporting (OPTIONAL) document_type: Type of document (OPTIONAL) project: Project/world the document belongs to (OPTIONAL)
JSON Example: { “content”: “Arasai wielded the Sword of Fate…”, “document_id”: “doc_123”, “path”: “documents/chapter_01.md”, “title”: “Chapter 1: The Beginning”, “document_type”: “story”, “project”: “my_project” }
Used By: - LoreKeeper consistency checking - Document analysis workflows - Cross-reference validation
Project type for lore rules (worldbuilding, custom, generic)
Analysis depth: minor, moderate, strict, deep. Legacy name kept for back-compat — new clients should send strictness on the unified off | low | medium | high scale instead. When both are sent, strictness wins.
Include fix suggestions for inconsistencies
Check consistency across all provided documents
M8: which scope to run the DE Lorekeeper handler against. document (default) matches the pre-M8 behavior; the other kinds let callers trigger broader scans without splitting the request.
Responses
Section titled “ Responses ”Successful Response
Lore consistency check response model.
Uses ResponseBuilder.success pattern for standardized response formatting. Provides comprehensive consistency check results including detected inconsistencies, validation status, per-document analysis, cross-document issues, and actionable recommendations.
Fields: status: Check status (success/error) message: Response message data: Detailed consistency check results (ConsistencyCheckData) timestamp: Response generation timestamp
JSON Example: { “status”: “success”, “message”: “Lore consistency check completed”, “data”: { “overall_score”: 85.3, “consistency_level”: “good”, “document_results”: […], “total_issues”: 3, “critical_issues”: 0 }, “timestamp”: “2025-01-20T10:30:00Z” }
Used By: - POST /api/agents/lorekeeper/check-consistency - Writing Module consistency UI - Lore validation workflows
object
Check status (success/error)
Response message
Detailed consistency check results
object
Overall consistency score (0.0-100.0)
Human-readable level: excellent, good, fair, poor, critical
Per-document analysis results
Consistency check results for a single document.
Contains analysis results, issues found, and consistency score for one document in the batch check.
Fields: document_id: Document identifier (OPTIONAL) document_title: Document title for reporting (OPTIONAL) consistency_score: Overall score for this doc (REQUIRED, 0.0-100.0) issues: List of issues found in this doc (REQUIRED) warnings_count: Number of warnings (REQUIRED) errors_count: Number of errors (REQUIRED) entities_found: Entities detected in doc (OPTIONAL)
JSON Example: { “document_id”: “doc_123”, “document_title”: “Chapter 1: The Beginning”, “consistency_score”: 87.5, “issues”: [ { “issue_type”: “timeline_conflict”, “severity”: “medium”, “description”: “Event date conflicts with established timeline” } ], “warnings_count”: 2, “errors_count”: 0, “entities_found”: [“John Smith”, “New York”, “Excalibur Sword”] }
Used By: - LoreKeeper consistency check responses - Per-document analysis reporting - Writing Module consistency display
object
Overall consistency score (0.0-100.0)
Issues found in this document
Individual lore consistency issue found during analysis.
Represents a specific inconsistency, conflict, or concern discovered during lore consistency checking with severity level and suggested fixes.
Fields: issue_type: Type of issue (REQUIRED) severity: Issue severity level (REQUIRED) description: Human-readable issue description (REQUIRED) location: Where the issue occurs (OPTIONAL) affected_entities: Entities involved in issue (OPTIONAL) suggestion: Suggested fix or resolution (OPTIONAL) confidence: AI confidence in detection (OPTIONAL, 0.0-1.0)
JSON Example: { “issue_type”: “character_contradiction”, “severity”: “high”, “description”: “Character age inconsistent between documents”, “location”: “document_1, paragraph 3”, “affected_entities”: [“John Smith”], “suggestion”: “Update age to match earlier reference (25 years)”, “confidence”: 0.92 }
Used By: - LoreKeeper consistency check responses - Consistency violation reporting - Fix suggestion systems
object
Type of issue (character_contradiction, timeline_conflict, lore_inconsistency, etc.)
Issue severity: critical, high, medium, low, minor
Human-readable description of the issue
DE handler model-id that produced this issue. Lorekeeper composes several sub-handlers (scene-contradictions, lore-ml-validation, entity-extract, prose-consistency); each sub-handler’s findings override this with the producer’s actual model-id.
Number of warnings found
Number of errors found
Individual lore consistency issue found during analysis.
Represents a specific inconsistency, conflict, or concern discovered during lore consistency checking with severity level and suggested fixes.
Fields: issue_type: Type of issue (REQUIRED) severity: Issue severity level (REQUIRED) description: Human-readable issue description (REQUIRED) location: Where the issue occurs (OPTIONAL) affected_entities: Entities involved in issue (OPTIONAL) suggestion: Suggested fix or resolution (OPTIONAL) confidence: AI confidence in detection (OPTIONAL, 0.0-1.0)
JSON Example: { “issue_type”: “character_contradiction”, “severity”: “high”, “description”: “Character age inconsistent between documents”, “location”: “document_1, paragraph 3”, “affected_entities”: [“John Smith”], “suggestion”: “Update age to match earlier reference (25 years)”, “confidence”: 0.92 }
Used By: - LoreKeeper consistency check responses - Consistency violation reporting - Fix suggestion systems
object
Type of issue (character_contradiction, timeline_conflict, lore_inconsistency, etc.)
Issue severity: critical, high, medium, low, minor
Human-readable description of the issue
DE handler model-id that produced this issue. Lorekeeper composes several sub-handlers (scene-contradictions, lore-ml-validation, entity-extract, prose-consistency); each sub-handler’s findings override this with the producer’s actual model-id.
Total issues found
Number of critical issues
Number of warning-level issues
Response generation timestamp
Validation Error