Ground the judge's quote with markdown emphasis and whitespace ignored #155
+7
-2
@@ -527,8 +527,13 @@ def complete(verdict):
|
||||
def grounded(verdict, transcript):
|
||||
if not verdict["interrupt"]:
|
||||
return True
|
||||
evidence = verdict["evidence"]
|
||||
return evidence.strip() != "" and evidence in transcript
|
||||
evidence = plain(verdict["evidence"])
|
||||
return evidence != "" and evidence in plain(transcript)
|
||||
|
||||
|
||||
def plain(text):
|
||||
# The judge drops markdown emphasis and reflows whitespace when it quotes.
|
||||
return " ".join(text.replace("*", "").replace("_", "").split())
|
||||
|
||||
|
||||
# ~/.claude.json
|
||||
|
||||
@@ -348,6 +348,12 @@ class Grounded(unittest.TestCase):
|
||||
self.assertFalse(loop.grounded({"interrupt": True, "evidence": ""}, "the transcript"))
|
||||
self.assertFalse(loop.grounded({"interrupt": True, "evidence": " "}, "the transcript"))
|
||||
|
||||
def test_a_quote_may_drop_markdown_emphasis_and_reflow_whitespace(self):
|
||||
transcript = "done.\n\n**Your step:**\n```\n./run.sh\n```\nRun it."
|
||||
self.assertTrue(loop.grounded({"interrupt": True, "evidence": "Your step:\n```\n./run.sh\n```\nRun it."}, transcript))
|
||||
self.assertTrue(loop.grounded({"interrupt": True, "evidence": "Your step: ``` ./run.sh ``` Run it."}, transcript))
|
||||
self.assertFalse(loop.grounded({"interrupt": True, "evidence": "**"}, transcript))
|
||||
|
||||
|
||||
class Verdict(unittest.TestCase):
|
||||
def test_needs_every_field_the_schema_requires(self):
|
||||
|
||||
Reference in New Issue
Block a user