def _extract_follow_up_question(self, text: str) -> Optional[dict]:
        """
        Extract follow-up question from JSON blocks in the response.

        Looks for JSON blocks containing follow_up_question at the end of responses.

        Args:
            text: The response text to parse

        Returns:
            Dict with follow-up data if found, None otherwise
        """
        # Look for JSON blocks that contain follow_up_question
        # Pattern handles optional leading whitespace and indentation
        json_pattern = r'```json\s*\n\s*(\{.*?"follow_up_question".*?\})\s*\n\s*```'
        matches = re.findall(json_pattern, text, re.DOTALL)

        if not matches:
            return None

        # Take the last match (most recent follow-up)
        try:
            # Clean up the JSON string - remove excess whitespace and normalize
            json_str = re.sub(r"\n\s+", "\n", matches[-1]).strip()
            follow_up_data = json.loads(json_str)
            if "follow_up_question" in follow_up_data:
                return follow_up_data
        except (json.JSONDecodeError, ValueError):
            pass

        return None

        Extract follow-up question from JSON blocks in the response.

        Looks for JSON blocks containing follow_up_question at the end of responses.

        Args:
            text: The response text to parse

        Returns:
            Dict with follow-up data if found, None otherwise
        
tools/base.py