feat: wire execution-boundary interception points#6517
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 5 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 790bde5. Configure here.
| flow=self, output=final_output, payload=final_output | ||
| ) | ||
| dispatch(InterceptionPoint.EXECUTION_END, end_ctx) | ||
|
|
There was a problem hiding this comment.
End hook after finished event
Medium Severity
EXECUTION_END is dispatched after FlowFinishedEvent and trace finalization. A HookAborted from that point still leaves listeners with a successful finished event while the caller sees an abort, and any returned payload replacement is ignored by the following return.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 790bde5. Configure here.
790bde5 to
ea20c1a
Compare
8bc4fa2 to
a85e100
Compare
Adds the typed interception contexts (`crewai/hooks/contexts.py`) and wires the `execution_start`, `input`, `output`, and `execution_end` points for both crews and flows through the dispatcher. `prepare_kickoff` and `Flow.kickoff_async` fire `execution_start`/`input` so a hook can rewrite resolved inputs before the run, while `Crew._create_crew_output` and the flow tail fire `output`/`execution_end` so the final result can be observed or replaced. Closes the eight critical-path points without touching the legacy hooks.
Reworks the crew and flow boundary seams flagged in review. `OUTPUT` and `EXECUTION_END` now run before the completion event (`CrewKickoffCompletedEvent` and `FlowFinishedEvent`) so a `HookAborted` no longer leaves a spurious completed signal and a returned payload replacement is honored on the emitted and returned result. Boundary contexts alias `inputs` to the same object as `payload` instead of a fresh dict from `or`, so in-place edits survive read-back. Flows re-publish the resolved inputs into `flow_inputs` baggage after the `INPUT` hook so trigger-payload injection observes hook rewrites, and a resumed flow now dispatches `OUTPUT`/`EXECUTION_END` on its completion path.
ea20c1a to
73bdfaa
Compare


With the dispatcher in place, the execution lifecycle still had no interception seams. This introduces the typed interception contexts and wires
execution_start,input,output, andexecution_endfor both crews and flows:prepare_kickoffandFlow.kickoff_asynclet a hook rewrite resolved inputs before a run, whileCrew._create_crew_outputand the flow tail let the final result be observed or replaced. It closes the eight critical-path points the policy engine needs without touching the legacy hooks. Stacked on #6516; part of the OSS-86 interception-hook catalog.