@@ -670,10 +670,27 @@ def new_status(state: EnvironmentState) -> str:
670
670
671
671
# now adjust to give the agent 2x pieces of evidence
672
672
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?"
673
676
response = await gather_evidence_tool .gather_evidence (
674
- session . question , state = env_state
677
+ new_question , state = env_state
675
678
)
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"
677
694
split = re .split (
678
695
r"(\d+) pieces of evidence, (\d+) of which were relevant" ,
679
696
response ,
@@ -899,6 +916,7 @@ def test_answers_are_striped() -> None:
899
916
contexts = [
900
917
Context (
901
918
context = "bla" ,
919
+ question = "foo" ,
902
920
text = Text (
903
921
name = "text" ,
904
922
text = "The meaning of life is 42." ,
0 commit comments