@@ -227,11 +227,12 @@ async def gather_evidence(self, question: str, state: EnvironmentState) -> str:
227227
228228 logger .info (f"{ self .TOOL_FN_NAME } starting for question { question !r} ." )
229229 original_question = state .session .question
230+ l1_all = l1_relevant = l0 = len (state .session .contexts )
231+
230232 try :
231233 # Swap out the question with the more specific question
232234 # TODO: remove this swap, as it prevents us from supporting parallel calls
233235 state .session .question = question
234- l0 = len (state .session .contexts )
235236
236237 # TODO: refactor answer out of this...
237238 state .session = await state .docs .aget_evidence (
@@ -244,7 +245,14 @@ async def gather_evidence(self, question: str, state: EnvironmentState) -> str:
244245 f"{ self .TOOL_FN_NAME } _aget_evidence"
245246 ),
246247 )
247- l1 = len (state .session .contexts )
248+ l1_all = len (state .session .contexts )
249+ l1_relevant = len (
250+ [
251+ c
252+ for c in state .session .contexts
253+ if c .score > state .RELEVANT_SCORE_CUTOFF
254+ ]
255+ )
248256 finally :
249257 state .session .question = original_question
250258
@@ -275,7 +283,10 @@ async def gather_evidence(self, question: str, state: EnvironmentState) -> str:
275283 )
276284 )
277285
278- return f"Added { l1 - l0 } pieces of evidence.{ best_evidence } \n \n " + status
286+ return (
287+ f"Added { l1_all - l0 } pieces of evidence, { l1_relevant - l0 } of which were"
288+ f" relevant.{ best_evidence } \n \n " + status
289+ )
279290
280291
281292class GenerateAnswer (NamedTool ):
0 commit comments