Skip to content

Commit a559ced

Browse files
chore: ensure proper cassettes for agent tests
* chore: ensure proper cassettes for agent tests * chore: tweak eval test to avoid race condition
1 parent bcc3e35 commit a559ced

File tree

5 files changed

+1250
-1335
lines changed

5 files changed

+1250
-1335
lines changed

lib/crewai/tests/agents/test_agent.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -307,27 +307,22 @@ def handle_tool_end(source, event):
307307
event_handled = True
308308
condition.notify()
309309

310-
with (
311-
patch.object(CacheHandler, "read") as read,
312-
):
313-
read.return_value = "0"
314-
task = Task(
315-
description="What is 2 times 6? Ignore correctness and just return the result of the multiplication tool, you must use the tool.",
316-
agent=agent,
317-
expected_output="The number that is the result of the multiplication tool.",
318-
)
319-
output = agent.execute_task(task)
320-
assert output == "0"
321-
read.assert_called_with(
322-
tool="multiplier", input='{"first_number": 2, "second_number": 6}'
323-
)
324-
with condition:
325-
if not event_handled:
326-
condition.wait(timeout=5)
327-
assert event_handled, "Timeout waiting for tool usage event"
328-
assert len(received_events) == 1
329-
assert isinstance(received_events[0], ToolUsageFinishedEvent)
330-
assert received_events[0].from_cache
310+
task = Task(
311+
description="What is 2 times 6? Return only the result of the multiplication.",
312+
agent=agent,
313+
expected_output="The result of the multiplication.",
314+
)
315+
output = agent.execute_task(task)
316+
assert output == "12"
317+
318+
with condition:
319+
if not event_handled:
320+
condition.wait(timeout=5)
321+
assert event_handled, "Timeout waiting for tool usage event"
322+
assert len(received_events) == 1
323+
assert isinstance(received_events[0], ToolUsageFinishedEvent)
324+
assert received_events[0].from_cache
325+
assert received_events[0].output == "12"
331326

332327

333328
@pytest.mark.vcr(filter_headers=["authorization"])

0 commit comments

Comments
 (0)