Skip to content

fix: wire ProvenaCrewListener to current CrewAI event bus API - #205

Open
Sharvari713 wants to merge 1 commit into
rajfirke:mainfrom
Sharvari713:fix/crewai-listener-registration-193
Open

Sharvari713 wants to merge 1 commit into
rajfirke:mainfrom
Sharvari713:fix/crewai-listener-registration-193

Conversation

@Sharvari713

Copy link
Copy Markdown
Contributor

What does this PR do?

ProvenaCrewListener never received real events — three separate problems
compounded into a silent no-op: it imported from a module path CrewAI no
longer has, it never implemented setup_listeners() (the method CrewAI's
BaseEventListener requires every subclass to define, so the bare
on_tool_usage_finished/on_agent_execution_completed methods were never
invoked by anything), and it read a nonexistent event.agent_name. A user
following the README's exact usage got zero trail records from a real
crew.kickoff() run, with no error anywhere.

The fix:

  • Switched imports from crewai.utilities.events.* to crewai.events
  • Implemented setup_listeners(), registering ToolUsageFinishedEvent and
    AgentExecutionCompletedEvent handlers via @crewai_event_bus.on(...)
  • Read agent identity via event.agent.role instead of the nonexistent
    event.agent_name

Verified end to end against a real installed crewai (1.15.22): constructed
real event objects, fired them through the real crewai_event_bus, confirmed
trail records appear with the correct source_name.

Also bumped the crewai extra's minimum from >=0.80 to >=1.0.0.
Confirmed by direct install/inspection in a throwaway venv, not a guess:
crewai 0.80.0 through 0.98.0 have neither the old nor the new event API
at all — they use a third, unrelated Emitter/emit/on decorator system.
The class-based event API this adapter depends on first appears at 1.0.0,
with the same fields (agent, output, tool_name) present through
1.15.22. crewai's own metadata pins <3.14,>=3.10 at both versions,
consistent with provena's own >=3.10 floor — no change needed there.

Rewrote tests/test_adapters.py's CrewAI fixture to fake the real API shape
(crewai.events, setup_listeners()/bus .on() registration) instead of
the old wrong module path, and rewrote all tests to fire through that
registration path instead of calling the old unbound methods directly.
Verified: all tests pass with crewai genuinely uninstalled, and all fail
against the reverted buggy adapter code (it can't even import successfully
under a correctly faked module layout — falls straight to the ImportError
placeholder).

Checklist

  • Tests added/updated for the change
  • ruff check src/ tests/ passes
  • ruff format --check src/ tests/ passes
  • mypy src/provena/ passes (1 pre-existing unrelated error on main, untouched by this change)
  • pytest passes with no failures (575 passed, 35 skipped — unrelated optional integrations)
  • CHANGELOG.md updated

Related Issues

Fixes #193

Switched imports from crewai.utilities.events.* to crewai.events.
Implemented setup_listeners(), registering ToolUsageFinishedEvent
and AgentExecutionCompletedEvent handlers via
@crewai_event_bus.on(...) -- the old bare on_tool_usage_finished/
on_agent_execution_completed methods were never invoked by
anything without this. Read agent identity via event.agent.role
instead of the nonexistent event.agent_name.

Verified end to end against a real installed crewai (1.15.22):
constructed real event objects, fired them through the real
crewai_event_bus, confirmed trail records appear with the correct
source_name.

Bumped the crewai extra's minimum from >=0.80 to >=1.0.0. Confirmed
by direct install/inspection: crewai 0.80.0 through 0.98.0 have
neither the old nor the new event API -- they use a third,
unrelated Emitter/emit/on decorator system. The class-based event
API this adapter depends on first appears at 1.0.0, with the same
fields (agent, output, tool_name) present through 1.15.22. crewai's
own metadata pins <3.14,>=3.10 at both versions, consistent with
provena's own >=3.10 floor -- no change needed there.

Rewrote tests/test_adapters.py's CrewAI fixture to fake the real
API shape (crewai.events, setup_listeners()/bus .on() registration)
instead of the old wrong module path, and rewrote all tests to fire
through that registration path instead of calling the old unbound
methods directly. Verified: all tests pass with crewai genuinely
uninstalled, and all fail against the reverted buggy adapter code.

Fixes rajfirke#193

This branch has not been deployed

No deployments
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.

Wire ProvenaCrewListener to current CrewAI event bus API

1 participant