crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] Crew.test crashes or misattributes scores when a ConditionalTask is skipped

Open Timotty opened this issue 1 month ago • 2 comments

Description

Crew.test() can raise IndexError after all iterations have completed when a ConditionalTask is skipped. Scores for subsequent tasks are shifted into the wrong rows; a trailing skip in only one run also omits another run's trailing score from the crew average.

Steps to Reproduce

  1. Create a crew with a regular task, a ConditionalTask whose condition sometimes returns False, and another regular task.
  2. Call crew.test(2, eval_llm=...) so the conditional task is skipped in at least one iteration. The regression tests in PR #7996 use mocked model calls and execute the real Crew.test() / kickoff() path.
  3. Observe IndexError: list index out of range in CrewEvaluator.print_crew_evaluation_result() or scores attributed to the wrong task.

Expected behavior

Skipped tasks display -; tasks that ran retain their scores; per-task and crew averages only include existing scores.

Screenshots/Code snippets

The evaluator assigns a callback to every task, but skipped ConditionalTasks never invoke it. print_crew_evaluation_result() indexes per-run score lists by every task position; a skipped task leaves a shorter list.

Operating System

Windows 11

Python Version

3.13 (local regression test environment)

crewAI Version

Repository main at 140bfcb (October 9, 2026)

crewAI Tools Version

Not needed to reproduce

Virtual Environment

Venv (uv-managed)

Evidence

Regression tests using the real Crew.test() path reproduce an IndexError before the fix. Targeted evaluator tests pass afterward (7 passed). A separate trailing-skip case demonstrates an incorrectly low overall average before the fix.

Possible Solution

Store scores at their task indices with placeholders for skipped tasks, and compute averages from actual scores. Proposed fix and regression tests: #7996.

Additional context

This issue and the linked PR were prepared with AI assistance; no external model calls are required for the regression tests.

Timotty avatar Oct 09 '26 21:10 Timotty

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 09 '26 12:11 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Nov 15 '26 12:11 github-actions[bot]