Skip to content

ADR-0004 — Media Type Detection Enhancement Strategy

Context

The tmdbGPT system experienced a critical mixed content issue where TV-specific queries returned both TV shows and movies: - Queries like "comedy shows" returned mixed TV and movie results - Queries like "horror films" worked correctly (movie-only results) - The issue specifically affected natural language TV queries using the term "shows" - Root cause analysis revealed incomplete natural language indicator coverage in media type detection

Problem Scale: - Affected all TV queries using "shows" terminology - Created poor user experience with irrelevant mixed content - Required systematic diagnosis to identify single-point failure in complex pipeline

Decision

Enhance media type detection by expanding natural language indicator coverage rather than restructuring the query processing pipeline.

Specific Technical Decision: Modify infer_media_type_from_query() function to include comprehensive TV indicators:

# Before: Limited TV indicators
tv_indicators = ["tv show", "series"]

# After: Comprehensive TV indicators  
tv_indicators = ["tv show", "series", "shows", "television", "episodes"]

Alternative Approaches Considered: 1. Query Rewriting: Transform "shows" to "tv show" during preprocessing 2. Pipeline Restructuring: Modify constraint validation to handle ambiguous media types 3. Context-Based Detection: Use surrounding query context for disambiguation 4. User Intent Clarification: Prompt users for media type specification

Decision Rationale: - Minimal Impact: Single-line change vs. pipeline overhaul - Maximum Coverage: Addresses root cause comprehensively - Preservation of Architecture: Maintains existing hybrid semantic/symbolic approach - Performance: No additional computational overhead

Consequences

Positive

  • 100% Resolution Rate: Completely eliminated mixed content issues across all TV query variations
  • Improved Semantic Understanding: Better natural language comprehension for TV queries
  • Architectural Simplicity: Solution aligns with existing media type detection strategy
  • No Regression: Movie queries ("horror films") continue working without impact
  • Scalable Pattern: Establishes approach for future natural language indicator gaps

Negative

  • Indicator Maintenance: Future natural language variations may require similar updates
  • Limited Scope: Addresses symptoms rather than fundamental disambiguation architecture

Validation Results

  • Test Coverage: "comedy shows", "drama shows", "reality shows" all resolved to TV-only results
  • Comparative Analysis: Working baseline ("horror films") maintained correct behavior
  • Edge Cases: No negative impact on ambiguous queries that should return "both"

Compliance

This decision follows established software engineering principles: - Principle of Least Change: Minimal modification for maximum impact - Single Responsibility: Media type detection function maintains clear purpose - Backward Compatibility: Existing functionality preserved without modification

  • Implements diagnostic methodology from ADR-0003 for systematic root cause analysis
  • Supports ADR-0002 chatbox architecture by enhancing the extraction stage
  • Establishes pattern for future natural language processing enhancements in the system