@@ -670,10 +670,27 @@ def new_status(state: EnvironmentState) -> str:
670670
671671 # now adjust to give the agent 2x pieces of evidence
672672 gather_evidence_tool .settings .agent .agent_evidence_n = 2
673+ # also reset the question to ensure that contexts are
674+ # only returned to the agent for the new question
675+ new_question = "How does XAI relate to a self-explanatory model?"
673676 response = await gather_evidence_tool .gather_evidence (
674- session . question , state = env_state
677+ new_question , state = env_state
675678 )
676-
679+ assert len ({c .question for c in session .contexts }) == 2 , "Expected 2 questions"
680+ # now we make sure this is only for the old question
681+ for context in session .contexts :
682+ if context .question != new_question :
683+ assert (
684+ context .context [:20 ] not in response
685+ ), "gather_evidence should not return any contexts for the old question"
686+ assert (
687+ sum (
688+ (1 if (context .context [:20 ] in response ) else 0 )
689+ for context in session .contexts
690+ if context .question == new_question
691+ )
692+ == 2
693+ ), "gather_evidence should only return 2 contexts for the new question"
677694 split = re .split (
678695 r"(\d+) pieces of evidence, (\d+) of which were relevant" ,
679696 response ,
@@ -899,6 +916,7 @@ def test_answers_are_striped() -> None:
899916 contexts = [
900917 Context (
901918 context = "bla" ,
919+ question = "foo" ,
902920 text = Text (
903921 name = "text" ,
904922 text = "The meaning of life is 42." ,
0 commit comments