Skip to content

Commit

Permalink
Added test of evidence added counts, to be sure it's correct
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza committed Jan 15, 2025
1 parent d561939 commit 0375de9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,17 @@ def new_status(state: EnvironmentState) -> str:
gather_evidence_initialized_callback.assert_awaited_once_with(env_state)
gather_evidence_completed_callback.assert_awaited_once_with(env_state)

split = re.split(
r"(\d+) pieces of evidence, (\d+) of which were relevant",
response,
maxsplit=1,
)
assert len(split) == 4, "Unexpected response shape"
total_added_1, relevant_added_1 = int(split[1]), int(split[2])
assert all(
x >= 0 for x in (total_added_1, relevant_added_1)
), "Expected non-negative counts"
assert len(env_state.get_relevant_contexts()) == relevant_added_1
# ensure 1 piece of top evidence is returned
assert "\n1." in response, "gather_evidence did not return any results"
assert (
Expand All @@ -591,6 +602,21 @@ def new_status(state: EnvironmentState) -> str:
response = await gather_evidence_tool.gather_evidence(
session.question, state=env_state
)

split = re.split(
r"(\d+) pieces of evidence, (\d+) of which were relevant",
response,
maxsplit=1,
)
assert len(split) == 4, "Unexpected response shape"
total_added_2, relevant_added_2 = int(split[1]), int(split[2])
assert all(
x >= 0 for x in (total_added_2, relevant_added_2)
), "Expected non-negative counts"
assert (
len(env_state.get_relevant_contexts())
== relevant_added_1 + relevant_added_2
)
# ensure both evidences are returned
assert "\n1." in response, "gather_evidence did not return any results"
assert "\n2." in response, "gather_evidence should return 2 contexts"
Expand Down

0 comments on commit 0375de9

Please sign in to comment.