crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] Crew.akickoff still does not await async kickoff callbacks (follow-up to #6481)

Open nolanchic opened this issue 2 months ago • 4 comments

Description

Crew.akickoff() does not await async before/after kickoff callbacks. An async before-callback's body is not executed when called by synchronous preparation; an async after-callback replaces the result with an unawaited coroutine before post-processing. This report continues #6481, which was closed for inactivity, not because a fix was merged.

Steps to Reproduce

  1. Create an otherwise working sequential Crew with a task and its assigned agent.
  2. Attach the async callback below to after_kickoff_callbacks.
  3. Run result = await crew.akickoff().
  4. Check whether the callback executed and the result remains a CrewOutput. Repeat with an async before-callback returning the input dict.

Expected behavior

The native async path awaits awaitable callback results, applies returned inputs/output, and executes each callback once. Synchronous callbacks retain their existing behavior. Offloading blocking synchronous callbacks is outside this report's scope.

Screenshots/Code snippets

called = False

async def after_callback(output):
    global called
    called = True
    return output

# Given an otherwise working Crew:
crew.after_kickoff_callbacks = [after_callback]
result = await crew.akickoff()
assert called

Operating System

Original report: macOS Sonoma. Current verification is source inspection, not a new OS-specific runtime reproduction.

Python Version

Original report: 3.12.

crewAI Version

Originally reported on 1.15.2; source inspected again on 2026-09-19 at main commit 3831e8b6c86f78cb3cde18ebf7be0d197b958f0e.

crewAI Tools Version

Not required: this concerns core Crew kickoff callbacks.

Virtual Environment

Venv (original report).

Evidence

Current main still calls synchronous prepare_kickoff in akickoff and directly assigns result = after_callback(result) without awaiting it: https://github.com/crewAIInc/crewAI/blob/3831e8b6c86f78cb3cde18ebf7be0d197b958f0e/lib/crewai/src/crewai/crew.py#L1275-L1289 . No fresh full-suite test run is claimed here.

Independent historical verification by ErenAta16 on #6500 covered (1) a callback returning None, (2) empty callbacks with inputs=None, and (3) the synchronous control case. The reviewer confirmed the distinct sentinel prevents duplicate callback execution and recommended retaining it: https://github.com/crewAIInc/crewAI/pull/6500#issuecomment-5049732531 . This is historical review evidence, not a maintainer approval of the latest rebased revision.

Possible Solution

Resume review of #6500: await an async preparation entry point and await after-callback results when awaitable. Preserve callback-chain None semantics and exactly-once execution. Validate current hook ordering and regressions against current main before merging.

Additional context

Five related implementation attempts are #6482, #6494, #6500, #6547, and #6697. All five are currently closed and none is recorded as merged. This is not a claim that their technical merits are identical.

Original report: #6481. It was automatically closed for inactivity on August 28. On September 17, #6500 was automatically closed because first-time contributors require an associated OPEN issue. The bot explicitly allows reopening after linking an open issue: https://github.com/crewAIInc/crewAI/pull/6500#issuecomment-5709744042 . This report supplies that active tracking issue while preserving the existing review history.

At inspection, #6500 head 7c202258fde62b7502403c09204f304062fb79e9 is 9 commits behind main; it is not claimed to be fully up to date.

AI disclosure: this issue was prepared with OpenAI Codex. The llm-generated label is requested per CONTRIBUTING.md.

nolanchic avatar Sep 19 '26 04:09 nolanchic

Hi team,

I would like to take this up. I can ensure Crew.akickoff properly awaits both before and after async kickoff callbacks while preserving existing synchronous callback behavior, along with unit tests.

Could you please assign this to me?

VimalN2005 avatar Sep 19 '26 06:09 VimalN2005

Thanks for offering, @VimalN2005! This one already has a complete fix up in #7608 — rebased onto current main, CodeRabbit-verified across three rounds, with tests covering the double-run, returns-None, and sentinel edge cases. It's just waiting on maintainer review.

If you'd like to help it along, running the branch against your setup or reviewing the diff would be genuinely useful — and if you find a case the tests don't cover, comment there and I'll extend the coverage.

nolanchic avatar Sep 30 '26 10:09 nolanchic

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 Oct 30 '26 12:10 github-actions[bot]

The issue is still relevant, and the async callback fix remains open in #7608. The PR is waiting for review — happy to update the branch (it's behind main) or address any feedback needed to move it forward.

One small ask for a maintainer: the PR discloses AI assistance in its description, so it still needs the llm-generated label added — contributors can't apply labels on this repo. Thanks!

nolanchic avatar Nov 02 '26 06:11 nolanchic