Skip to content

feat: support crewai 1.9.3#484

Merged
Focadecombate merged 7 commits intomainfrom
feature/sc-56095/support-crewai-1-9-3
Feb 25, 2026
Merged

feat: support crewai 1.9.3#484
Focadecombate merged 7 commits intomainfrom
feature/sc-56095/support-crewai-1-9-3

Conversation

@Focadecombate
Copy link
Contributor

@Focadecombate Focadecombate commented Feb 23, 2026

User description

Shortcut: https://app.shortcut.com/galileo/story/56095

Description:

Adds support for CrewAI 1.9.3 with three key fixes:

  • New event module paths: CrewAI >= 0.177.0 moved event types from
    crewai.utilities.events.* to crewai.events.*. The handler now detects the
    installed version and imports from the correct path, with lazy imports preserved to
    avoid pytest-xdist worker hangs.
  • Fix CPython __bases__ assignment error: The lazy import approach from chore: change crew ai imports to be lazy #477
    dynamically reassigned CrewAIEventListener.__bases__, which CPython rejects when the
    base class has a different deallocator. Replaced with direct event bus registration
    in __init__ — same behavior, no inheritance required.
  • Capture LLM token usage: _handle_llm_call_completed now extracts
    prompt_tokens, completion_tokens, and total_tokens from the response object (via
    response.usage, response.model_extra["usage"], or source._token_usage dict
    fallback).
  • Fix empty tool outputs: Tool event run_id generation used event_id (unique per
    emission), producing different IDs for start vs finish events since CrewAI 1.9.3
    doesn't populate started_event_id/previous_event_id on end events. Now uses
    deterministic tool_name + tool_args hash so end_node always finds the matching
    started node.

Tests:

  • Unit Tests Added
  • E2E Test Added (if it's a
    user-facing feature, or fixing a bug)

Generated description

Below is a concise technical summary of the changes proposed in this PR:
Updates the CrewAIEventListener to support CrewAI 1.9.3 by adapting to new event module paths and resolving a CPython error related to dynamic base class assignment. Enhances tracing accuracy and observability by implementing a robust, deterministic ID generation strategy for various event types and extracting detailed LLM token usage metrics.

TopicDetails
CrewAI Compatibility Ensures compatibility with CrewAI versions by dynamically resolving event module paths (for versions >= 0.177.0) and refactoring the CrewAIEventListener to register directly with the event bus instead of using dynamic inheritance, which resolves a CPython deallocator error. This also updates core dependencies to support the new CrewAI version.
Modified files (3)
  • poetry.lock
  • pyproject.toml
  • src/galileo/handlers/crewai/handler.py
Latest Contributors(2)
UserCommitDate
ci@rungalileo.iochore-release-v1.47.0February 21, 2026
Focadecombatechore-change-crew-ai-i...February 20, 2026
Tracing & Metrics Improves the quality and correlation of logged traces within the CrewAIEventListener by introducing a static _hash_to_uuid helper and refining the _generate_run_id method. This new logic provides deterministic run ID generation for memory, LLM (using call_id for CrewAI >= 1.0), and tool events (using tool_name + tool_args hash), ensuring accurate linking of start and end events. Additionally, it enhances LLM call completion handling to extract prompt_tokens, completion_tokens, and total_tokens from various response structures, and adds support for logging memory retrieval failures. Robustness for parent ID resolution in agent, task, and tool events is also improved for CrewAI >= 1.0.
Modified files (2)
  • src/galileo/handlers/crewai/handler.py
  • tests/test_crewai_handler.py
Latest Contributors(2)
UserCommitDate
Focadecombatechore-change-crew-ai-i...February 20, 2026
vamaq@users.noreply.gi...chore-Add-support-for-...December 26, 2025
This pull request is reviewed by Baz. Review like a pro on (Baz).

@Focadecombate Focadecombate requested a review from a team as a code owner February 23, 2026 15:18
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 80.30303% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.89%. Comparing base (0e364eb) to head (a905777).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/galileo/handlers/crewai/handler.py 80.30% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #484      +/-   ##
==========================================
+ Coverage   81.85%   81.89%   +0.04%     
==========================================
  Files          96       96              
  Lines        9164     9190      +26     
==========================================
+ Hits         7501     7526      +25     
- Misses       1663     1664       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@fernandocorreia-galileo fernandocorreia-galileo left a comment

Choose a reason for hiding this comment

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

I have 2 minor points plus one concern about tool run_id collision.

[tool.poetry.dependencies]
python = "^3.10,<3.15"
pydantic = "^2.12.0"
pydantic = "^2.11.9"
Copy link
Contributor

Choose a reason for hiding this comment

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

pydantic lower bound was changed from ^2.12.0 to ^2.11.9. The PR description doesn't explain why. If this is a crewai compatibility requirement, it should be mentioned. Widening dependency bounds without explanation risks introducing subtle compatibility issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've widened due to crew-ai constraints, so it would have a matching version.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Focadecombate what is the crew-ai constraint? Does it not work with pydantic >= 2.12.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was 2.11.9 as of yesterday.

Focadecombate and others added 2 commits February 24, 2026 14:56
Include agent_id in tool event hash to prevent UUID collisions when
different agents call the same tool with identical arguments.

Add type guard to memory query event detection to prevent false positives
from other events that happen to have a query attribute.
The test was failing because error_event lacked agent_id which is used
in the run_id hash computation for tool events.
Copy link
Contributor

@savula15 savula15 left a comment

Choose a reason for hiding this comment

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

LGTM

@Focadecombate Focadecombate merged commit dba40f6 into main Feb 25, 2026
33 of 34 checks passed
@Focadecombate Focadecombate deleted the feature/sc-56095/support-crewai-1-9-3 branch February 25, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants