Files
crewAI/lib/crewai/tests/utils.py
alex-clawd c14abf1758
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Check Documentation Broken Links / Check broken links (push) Has been cancelled
Nightly Canary Release / Check for new commits (push) Has been cancelled
Nightly Canary Release / Build nightly packages (push) Has been cancelled
Nightly Canary Release / Publish nightly to PyPI (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
fix: add GPT-5 and o-series to multimodal vision prefixes (#5183)
* fix: add GPT-5, o3, o4-mini to multimodal vision prefixes

Added verified vision-capable models:
- gpt-5 (all GPT-5 family — confirmed multimodal via openai.com)
- o3, o3-pro (full multimodal — openai.com/index/thinking-with-images)
- o4-mini, o4 (full multimodal)

Added text-only exclusion list to prevent false positives:
- o3-mini (text-only, replaced by o4-mini)
- o1-mini (text-only)
- o1-preview (text-only)

Existing prefixes unchanged (Claude 3+, Gemini, GPT-4).

* fix: add o1 to vision prefixes + ruff format

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: guard _sync_executor access in test utils for lazy-init event bus

* fix: expand vision model coverage — Claude 5, Grok, Pixtral, Qwen VL, LLaVA

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* ci: retrigger — flaky test_hierarchical_verbose_false_manager_agent (ConnectionError)

* fix: remove hallucinated claude-5 models from vision prefixes — verified against official docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: João Moura <joaomdmoura@gmail.com>
2026-04-01 18:08:37 -03:00

42 lines
1.4 KiB
Python

"""Test utilities for CrewAI tests."""
import asyncio
from concurrent.futures import ThreadPoolExecutor
def wait_for_event_handlers(timeout: float = 5.0) -> None:
"""Wait for all pending event handlers to complete.
This helper ensures all sync and async handlers finish processing before
proceeding. Useful in tests to make assertions deterministic.
Args:
timeout: Maximum time to wait in seconds.
"""
from crewai.events.event_bus import crewai_event_bus
loop = getattr(crewai_event_bus, "_loop", None)
if loop and not loop.is_closed():
async def _wait_for_async_tasks() -> None:
tasks = {
t for t in asyncio.all_tasks(loop) if t is not asyncio.current_task()
}
if tasks:
await asyncio.gather(*tasks, return_exceptions=True)
future = asyncio.run_coroutine_threadsafe(_wait_for_async_tasks(), loop)
try:
future.result(timeout=timeout)
except Exception: # noqa: S110
pass
# Guard against lazy-initialized executor (may not exist if no events were emitted)
if getattr(crewai_event_bus, "_executor_initialized", False):
crewai_event_bus._sync_executor.shutdown(wait=True)
crewai_event_bus._sync_executor = ThreadPoolExecutor(
max_workers=10,
thread_name_prefix="CrewAISyncHandler",
)