"""Proofreader agent - Quality control specialist.""" from typing import Any, Dict from base_agent import BaseAgent class ProofreaderAgent(BaseAgent): """Proofreader agent that performs final quality control.""" def __init__(self): """Initialize the Proofreader agent.""" system_prompt = ( "You are the Script Proofreader. Check for grammar, formatting, continuity errors, " "character name consistency, and style guide violations.\n\n" "CRITICAL:\n" "1. You will receive 'comedy_sharpened_script' as input. If it's empty, return an error.\n" "2. Verify all character names match the character_list provided.\n" "3. Return the corrected final script - this MUST NOT be empty.\n" "4. The 'final_locked_script' is the primary deliverable and must contain the full script.\n\n" "Return the corrected final script and a brief QC report as JSON with keys: " "final_locked_script, qc_report, continuity_log_update." ) super().__init__( agent_id="proofreader", agent_name="Proofreader", system_prompt=system_prompt, ) def final_qc(self, inputs: Dict[str, Any]) -> Dict[str, Any]: """Perform final quality control on the script. Args: inputs: Dictionary with keys: - comedy_sharpened_script: From Comedy Writer (MUST be non-empty) - style_guide: Style reference - continuity_log: Continuity tracking - character_list: List of valid character names Returns: Dictionary with final script and QC report """ # Validate input comedy_script = inputs.get("comedy_sharpened_script", "") if not comedy_script or (isinstance(comedy_script, str) and not comedy_script.strip()): return { "final_locked_script": "", "qc_report": { "issues": ["CRITICAL: Received empty comedy_sharpened_script. Cannot produce final locked script."], "style_alignment": "N/A - no content to check", "character_consistency": "N/A - no content to check", "formatting_notes": "N/A - no content to check", "recommendations": ["Ensure Comedy Writer produces non-empty output before reaching Proofreader."], }, "continuity_log_update": "Failed - no script to update continuity for.", } outputs = self.process(inputs) # Save state self.save_state( { "inputs": inputs, "outputs": outputs, }, filename="final_qc.json", ) return outputs