CLI-29: Robust Interruption in Agent Mode + Various Fixes#523
Merged
Conversation
|
Very cool thank you! Ctrl+C after seeing the AI go off the rails in console is an essential feature! |
Merged
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
This PR addresses CLI-29: making interruption in agent mode more robust, along with several related fixes and improvements discovered during investigation.
Changes
Core Interruption Fixes
cecli/helpers/coroutines.py: Removedtry/finallywrapper frominterruptible_async_generatorto preventCancelledErrorfrom being swallowed during cleanup. RemovedNonecheck forinterrupt_event(always required).cecli/coders/base_coder.py: Changedinterruptedexception fromasyncio.CancelledErrorback toKeyboardInterruptfor proper propagation. Removed staleinterrupt_event.clear()before formatting to avoid re-catching previous interrupts.cecli/tui/worker.py: AddedKeyboardInterrupthandler toCoderWorkerto prevent thread crashes when interruption occurs during TUI operation.Coder Switching & MCP Lifecycle Fixes
cecli/coders/base_coder.py:UsageMetametaclass, simplified to plainCoderclass with instance-level token/cost trackingedit_formatresolution logic (no longer overrides withmain_model.edit_formatfor "code" format)Coder.create()tomain.pywhere coder switching occursmcp_manager,tui,context_management_enabled, and token/cost accumulators between coderscecli/main.py: Disconnects "Local" MCP server when switching from agent to non-agent coder at the switch point rather than during coder creationSub-Agent & Delegation Changes
cecli/coders/agent_coder.py: Removedallow_nested_delegationconfig option - sub-agents always haveDelegatetool excludedcecli/coders/sub_agent_coder.py: Always excludesDelegatetool from sub-agentscecli/helpers/conversation/integration.py: Sub-agents context block only shown for primary coders (noparent_uuid)cecli/commands/spawn_agent.py: Simplified switch hint textagent-mode.mdandsubagents.mdto reflect removal ofallow_nested_delegationLinter Fixes
cecli/commands/lint.py: Changedlinter.lint()fromawaitto synchronous call (linter is no longer async)tests/basic/test_linter.py: Updated tests to match synchronous linter APIMinor Fixes
cecli/helpers/skills.py: Removed unnecessaryPath()wrappingcecli/coders/base_coder.py: Changed usage report separator from space to newline for better readabilitycecli/prompts/agent.yml,cecli/prompts/subagent.yml: Fixed typo "allows you too" → "allows you to"tests/coders/test_coder_switching.py: Test was fragile and tightly coupled to implementation details that changedTesting