refactor: sever the agentic-mode imports from the classic handlers - #237
Open
claude[bot] wants to merge 3 commits into
Open
claude[bot] wants to merge 3 commits into
claude[bot] wants to merge 3 commits into
Conversation
Agentic mode pulled _format_error_message and _update_working_directory_from_claude_response out of src/bot/handlers/message.py at seven call sites, and registered restart_command and sync_threads from src/bot/handlers/command.py. That is what made classic mode undeletable. The two helpers move to src/bot/utils/error_messages.py and src/bot/utils/working_directory.py. The two commands, which both modes register, move to src/bot/commands.py together with the _is_private_chat predicate sync_threads needs. Classic mode imports all of them from the new homes, so behaviour is unchanged in either mode. The only `from .handlers` import left in orchestrator.py is the classic registration inside _register_classic_handlers. A new test parses the orchestrator's AST and fails if another one appears, and checks that the three new shared modules do not reach back into handlers/. Tests that patched the helpers on handlers.message now patch the names the orchestrator binds at module level. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uta5V6wHoXYU3muwEpvaDt
|
No findings meet the merge-blocking bar at this head. |
8 of 13 tasks
Resolves the CHANGELOG.md conflict under [Unreleased]: this branch's Changed entry and main's Fixed entries from #239 are both kept. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uta5V6wHoXYU3muwEpvaDt
…q9g8 Resolves one conflict in src/bot/handlers/message.py: both sides added an import on adjacent lines (_format_error_message from its new home in src/bot/utils/error_messages.py, and with_stop_reason from #236). Both are kept. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uta5V6wHoXYU3muwEpvaDt
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.
Requested by Richard · project thread
Description
Before: agentic mode depended on classic mode.
src/bot/orchestrator.pyhad ninefrom .handlerslines:_format_error_messageimported inline at four error sites,_update_working_directory_from_claude_responseat three success sites, andfrom .handlers import commandto register/restartand/sync_threads. Deletingsrc/bot/handlers/would have broken every agentic reply path.After: the orchestrator imports nothing from
src/bot/handlers/except the classic registration inside_register_classic_handlers. Nothing changes for a user in either mode; every moved function is byte-for-byte the same code at a new path.This is step 1 of the classic-mode removal (roadmap item 4.1). It ships in 1.x and is non-breaking.
How
Two shared helpers leave
src/bot/handlers/message.py:_format_error_message(with its_format_process_errorcompanion) →src/bot/utils/error_messages.py_update_working_directory_from_claude_response→src/bot/utils/working_directory.pyTwo commands leave
src/bot/handlers/command.py, because agentic mode registers them too, so they were never classic-mode code:restart_commandandsync_threads→src/bot/commands.py, together with the_is_private_chatpredicatesync_threadsneeds. Classicstart_commandimports_is_private_chatfrom there.orchestrator.pybinds all four at module level instead of importing them inside each function. The three tests that patchedsrc.bot.handlers.message.<helper>now patchsrc.bot.orchestrator.<helper>, and the/restartand/sync_threadstests import fromsrc.bot.commands.A new test,
tests/unit/test_bot/test_agentic_imports.py, parses the orchestrator's AST and asserts the onlyfrom .handlersimport is the classic registration; it also checks the three new shared modules do not reach back intohandlers/. That is the "done when" condition of this step, kept enforced.CLAUDE.mdgains the two new modules under Key Directories and a note that agentic code must not import fromsrc/bot/handlers/.Merged with
mainafter #236 and #239 landed. The #236 merge had one conflict, two adjacent import lines insrc/bot/handlers/message.py, and both imports are kept. #236's own guard test (everyformat_claude_response()call goes throughwith_stop_reason()) passes on the merged head.Related issue
Groundwork for roadmap item 4.1 (classic-mode removal),
docs/ROADMAP-v2.md. No issue closes.Type of change
How it was tested
tests/unit/test_bot/test_agentic_imports.py(2 tests); patch targets updated intest_stop_button.py,test_orchestrator.py,test_thread_mode_handlers.pypoetry run pyteston the merged head: 691 passed (689 onmainafter fix: say why a run stopped instead of reporting success #236, plus the 2 new).black --check,isort --check-onlyandflake8pass. mypy is not a gate and was not run./restart,/sync_threadsand agentic reply tests cover the new import paths.Checklist
CHANGELOG.mdhas an entry under[Unreleased]pyproject.tomldependency changesCLAUDE.md. No settings or commands changed, so no.env.exampleordocs/change🤖 Generated with Claude Code
https://claude.ai/code/session_01Uta5V6wHoXYU3muwEpvaDt