feat(crew): add on_event hook so overrides can't silence the agent - #71
Open
abhishekmishragithub wants to merge 1 commit into
Open
feat(crew): add on_event hook so overrides can't silence the agent#71abhishekmishragithub wants to merge 1 commit into
abhishekmishragithub wants to merge 1 commit into
Conversation
OutputCrewNode.process_event carried the framework routing (LLM request -> generate_response, transcript -> context, settings), so a subclass that overrode process_event without super() silently dropped it — the agent stopped responding (0 turns). Extract that routing into a private _route_framework_event() and add an on_event() hook as the documented, super()-free extension point. process_event now runs: interrupt -> framework routing -> on_event -> forward. Overriding on_event can't drop framework routing; overriding process_event is discouraged in the docstring. Legacy process_event-with-super() overrides still work. Backward-compatible, scoped to OutputCrewNode (RootNode/SinkNode/Background legitimately override process_event without super and are untouched). Tests cover the on_event path and the legacy super() path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OutputCrewNode.process_eventcarries the framework routing —SDKSystemLLMRequestEvent -> _handle_llm_request(the LLM turn), transcript -> context, settings updates. A subclass that overridesprocess_eventwithoutsuper()silently drops all of it and the agent stops responding (the "0 turns, silent" symptom we hit).Fix (per review)
Extract the routing into a private
_route_framework_event()and add anon_event()hook as the documented,super()-free extension point:Overriding
on_eventcan't silence the agent; overridingprocess_eventis discouraged in the docstring.Scope + backward compat
Contained to
OutputCrewNode. RootNode/SinkNode/BackgroundCrewNode legitimately overrideprocess_eventwithoutsuper()(no framework routing, and Background deliberately skips interrupts) — untouched, so interrupt semantics don't change anywhere. Legacyprocess_event-with-super()overrides keep working.Tests
tests/custom/test_output_node_on_event_hook.py: (1) overridingon_eventwithout super keeps the LLM routing; (2) legacyprocess_event+super still routes. Both green.Pairs with #70 (Ready-before-nodes). Both are the SDK-side lifecycle footguns behind why node-level greeting attempts silenced the agent. No version bump — bundle into 5.4.0.
🤖 Generated with Claude Code