Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moved 'Best evidence(s)' to bulleted list, to avoid implying an order
  • Loading branch information
jamesbraza committed Sep 27, 2025
commit d26682ec602d5d622aade05d286485ecf30fc8dc
4 changes: 2 additions & 2 deletions src/paperqa/agents/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ async def gather_evidence(self, question: str, state: EnvironmentState) -> str:
reverse=True,
)

top_contexts = "\n".join(
top_contexts = "\n\n".join(
[
f"{n + 1}. {sc.context}\n"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note there was trailing whitespace here previously, now there's not

f"- {sc.context}"
for n, sc in enumerate(
sorted_contexts[: self.settings.agent.agent_evidence_n]
)
Expand Down
12 changes: 5 additions & 7 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,9 @@ def new_status(state: EnvironmentState) -> str:
total_added_1 = int(split[1])
assert total_added_1 > 0, "Expected non-negative added evidence count"
assert len(env_state.get_relevant_contexts()) == total_added_1
# ensure 1 piece of top evidence is returned
assert "\n1." in response, "gather_evidence did not return any results"
assert (
"\n2." not in response
), "gather_evidence should return only 1 context, not 2"
response.count("\n- ") == 1
), "Expected exactly one best evidence to be shown"

# now adjust to give the agent 2x pieces of evidence
gather_evidence_tool.settings.agent.agent_evidence_n = 2
Expand Down Expand Up @@ -745,9 +743,9 @@ def new_status(state: EnvironmentState) -> str:
total_added_2 = int(split[1])
assert total_added_2 > 0, "Expected non-negative added evidence count"
assert len(env_state.get_relevant_contexts()) == total_added_1 + total_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"
assert (
response.count("\n- ") == 2
), "Expected both evidences to be shown as best evidences"

assert session.contexts, "Evidence did not return any results"
assert not session.answer, "Expected no answer yet"
Expand Down