From eb348a5f3d9bfc8c28f3908527a659df38d4e20e Mon Sep 17 00:00:00 2001 From: openhands Date: Mon, 3 Nov 2025 17:09:16 +0000 Subject: [PATCH] Remove KeyboardInterrupt exit behavior from main chat loop - Change KeyboardInterrupt handler to continue loop instead of exiting - Let signal handler manage Ctrl+C behavior completely - Only exit on explicit /exit command or outer KeyboardInterrupt This ensures that Ctrl+C during agent processing returns to chat loop instead of exiting the entire application. Co-authored-by: openhands --- openhands-cli/openhands_cli/agent_chat.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/openhands-cli/openhands_cli/agent_chat.py b/openhands-cli/openhands_cli/agent_chat.py index 0d78c941ce..8eec5d66ec 100644 --- a/openhands-cli/openhands_cli/agent_chat.py +++ b/openhands-cli/openhands_cli/agent_chat.py @@ -219,18 +219,14 @@ def run_cli_entry(resume_conversation_id: str | None = None) -> None: except KeyboardInterrupt: # KeyboardInterrupt should be handled by the signal handler now - # This is a fallback in case the signal handler doesn't catch it - exit_confirmation = exit_session_confirmation() - if exit_confirmation == UserConfirmation.ACCEPT: - print_formatted_text(HTML('\nGoodbye! 👋')) - _print_exit_hint(conversation_id) - break + # Just continue the loop - the signal handler manages the process + continue except Exception as e: print_formatted_text(HTML(f'Error in chat loop: {e}')) continue except KeyboardInterrupt: - # Final fallback for KeyboardInterrupt + # Final fallback for KeyboardInterrupt - only exit if we're not in the main loop print_formatted_text(HTML('\nGoodbye! 👋')) _print_exit_hint(conversation_id)