chore: ensure proper cassettes for agent tests
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Notify Downstream / notify-downstream (push) Has been cancelled

* chore: ensure proper cassettes for agent tests
* chore: tweak eval test to avoid race condition
This commit is contained in:
Greyson LaLonde
2025-11-24 12:29:11 -05:00
committed by GitHub
parent bcc3e358cb
commit a559cedbd1
5 changed files with 1831 additions and 1916 deletions

View File

@@ -307,27 +307,22 @@ def test_cache_hitting():
event_handled = True
condition.notify()
with (
patch.object(CacheHandler, "read") as read,
):
read.return_value = "0"
task = Task(
description="What is 2 times 6? Ignore correctness and just return the result of the multiplication tool, you must use the tool.",
agent=agent,
expected_output="The number that is the result of the multiplication tool.",
)
output = agent.execute_task(task)
assert output == "0"
read.assert_called_with(
tool="multiplier", input='{"first_number": 2, "second_number": 6}'
)
with condition:
if not event_handled:
condition.wait(timeout=5)
assert event_handled, "Timeout waiting for tool usage event"
assert len(received_events) == 1
assert isinstance(received_events[0], ToolUsageFinishedEvent)
assert received_events[0].from_cache
task = Task(
description="What is 2 times 6? Return only the result of the multiplication.",
agent=agent,
expected_output="The result of the multiplication.",
)
output = agent.execute_task(task)
assert output == "12"
with condition:
if not event_handled:
condition.wait(timeout=5)
assert event_handled, "Timeout waiting for tool usage event"
assert len(received_events) == 1
assert isinstance(received_events[0], ToolUsageFinishedEvent)
assert received_events[0].from_cache
assert received_events[0].output == "12"
@pytest.mark.vcr(filter_headers=["authorization"])