From f5d67bd11c1228c21c3a6d91ff4fc9db71de2313 Mon Sep 17 00:00:00 2001 From: Lucas Gomide Date: Tue, 14 Jul 2026 02:37:08 -0300 Subject: [PATCH] fix: keep crew output typed across boundary hook dispatch `_create_crew_output` reassigned `crew_output` from the hook contexts' `payload`, which is typed `Any`, so mypy flagged `no-any-return` at the function's return. Cast the payload back to `CrewOutput` after each dispatch and split the `ExecutionEndContext` construction to satisfy `ruff format`'s line-length limit. --- lib/crewai/src/crewai/crew.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/crewai/src/crewai/crew.py b/lib/crewai/src/crewai/crew.py index ea0272c04..686b08cc4 100644 --- a/lib/crewai/src/crewai/crew.py +++ b/lib/crewai/src/crewai/crew.py @@ -1920,11 +1920,13 @@ class Crew(FlowTrackable, BaseModel): output_ctx = OutputContext(crew=self, output=crew_output, payload=crew_output) dispatch(InterceptionPoint.OUTPUT, output_ctx) - crew_output = output_ctx.payload + crew_output = cast(CrewOutput, output_ctx.payload) - end_ctx = ExecutionEndContext(crew=self, output=crew_output, payload=crew_output) + end_ctx = ExecutionEndContext( + crew=self, output=crew_output, payload=crew_output + ) dispatch(InterceptionPoint.EXECUTION_END, end_ctx) - crew_output = end_ctx.payload + crew_output = cast(CrewOutput, end_ctx.payload) # Ensure background memory saves finish (and emit their # completed/failed events) before the kickoff-completed event below