Repository navigation
refactor(agent): extract turn hook assembly - #4848
Merged
Merged
Conversation
Re-bin
approved these changes
Jul 8, 2026
Re-bin
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. This keeps the hook refactor on the right side of the line: loop.py still owns turn flow, while the per-turn hook assembly moves into a focused helper with explicit context and ordering. The new factory path is isolated, ephemeral turns preserve the previous extra-hook behavior, and SelfTool blocks the new private hook factory state from runtime mutation.
Validated locally:
python -m pytest tests/agent/test_hook_composite.py tests/agent/test_turn_hooks.py -qpython -m ruff check nanobot/agent/hook.py nanobot/agent/turn_hooks.py nanobot/agent/loop.py nanobot/agent/tools/self.py tests/agent/test_hook_composite.py tests/agent/test_turn_hooks.py
GitHub Actions is green across the full matrix.
This was referenced Jul 9, 2026
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.
Summary
AgentLoop._run_agent_loopintonanobot.agent.turn_hooks.AgentLoopresponsible for turn orchestration whileturn_hooksowns progress hook composition and ephemeral hook filtering.Verification
PYTHONPATH=. pytest tests/agent/test_turn_hooks.py tests/agent/test_hook_composite.py tests/agent/test_loop_direct_websocket_status.py -qPYTHONPATH=. pytest tests/agent/test_loop_progress.py tests/agent/test_runner_hooks.py -qPYTHONPATH=. pytest tests/test_nanobot_facade.py -qruff check nanobot/agent/loop.py nanobot/agent/turn_hooks.py tests/agent/test_turn_hooks.py