forge
Explore
Log in

Don't you dare go Hollow

Store an abstain when a reasoning plan has no cited sentence

Browse files at this commit

c66abbbeecf641b04a013334f418c7a53ffac02dAhmet Kaan GümüşParent: b867bdd
  • fix
    • store an abstain when a reasoning plan has no cited sentence
Show full message
fix: store an abstain when a reasoning plan has no cited sentence

A plan with no [N] became an empty string. The backend refuses to store
an empty reply, so the study thread showed bad_reply instead of the
missing-sources sentence.
Local-Gate: 4e696f1d77810c2e0425ec57f5940f309d671aff (1407 passed, 35s)
src/generate/prompt.pymodified+3 -1
@@ -68,7 +68,9 @@ def drop_reasoning_plan(text: str) -> str:
68 continue68 continue
69 if _CITED.search(line):69 if _CITED.search(line):
70 kept.append(line)70 kept.append(line)
71- return "\n".join(kept)71+ # An empty string is not storable. A plan with no cited sentence is an
72+ # abstain, not a blank bubble the backend rejects as bad_reply.
73+ return "\n".join(kept) if kept else ABSTAIN_SENTENCE
72 74
73 75
74 76
tests/unit/test_query_sanitization.pymodified+5 -0
@@ -125,6 +125,11 @@ class ReasoningPlanTests(unittest.TestCase):
125 text = "C# bir programlama dilidir. [1]"125 text = "C# bir programlama dilidir. [1]"
126 self.assertEqual(drop_reasoning_plan(text), text)126 self.assertEqual(drop_reasoning_plan(text), text)
127 127
128+ def test_a_plan_with_no_citation_is_the_abstain_sentence(self):
129+ raw = "We need to answer the student's question.\nSource 1: notes.\n"
130+ self.assertEqual(drop_reasoning_plan(raw), "Kaynaklarda bu bilgi bulunamadı.")
131+
132+
128 133
129 if __name__ == "__main__":134 if __name__ == "__main__":
130 unittest.main()135 unittest.main()