I feel like there's some conflation between the actual "Jedi teaching" and the feelings of each individual Jedi involved. If we're looking on the original trilogy on their own, the Jedi teaching basically only boils down to "believe in the Force" and "do not give in to anger". There's a nary a hint that these Jedi ways are outdated and as Luke chose to let go of his hatred and proclaimed "I am a Jedi, like my father before me," he's adhering to the Jedi code as far as he's concerned. That Vader must be killed is shown more as Obi-Wan's and Yoda personal opinion rather than them conveying some kind of a teaching.
If we're putting the prequel trilogy into the discussion, then both Obi-Wan's and Yoda's sentiments become even more justified. Here the Jedi is depicted as at least partly to blame for their own downfall with their outdated and inflexible ways, but "you must kill the murderous servant of evil" was never a part of that. If anything, one could argue that their failure actually include not being able to do it quickly enough. It's not like they can just sit down with Dooku and Palpatine and hear their concerns to maybe reach some kind of an understanding.
And after Obi-Wan continuously pleaded for Anakin to turn back to no avail even after he massacred everyone in the temple, after Anakin lied there defeated, continuously spewing that he hated him, Obi-Wan still didn't have the heart to kill him because he's a dear friend. That must have a been a very big regret haunting him for years.