Skip to content

[Bug]: Ctrl+C can skip exit prompt and terminate CLI immediately #9690

Open
@llamantino

Description

@llamantino

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • I have checked the existing issues.

Describe the bug and reproduction steps

The CLI currently doesn't handle Ctrl+C properly in some states. Pressing it can cause the CLI to exit immediately without showing the expected exit prompt.

In the CLI, Ctrl+C is currently handled in three different ways:

  • By the message input prompt (when active)
  • By the agent pause listener (active only when the agent is in the running state)
  • In all other cases, a fallback signal handler is triggered, which causes the CLI to exit without confirmation

This fallback behavior can cause the CLI to terminate unexpectedly if Ctrl+C is pressed at the wrong time - for example, right after submitting a message but before the agent has started working.

Reproduction steps

  1. Start the CLI
  2. Type a message and press Enter
  3. Press Ctrl+C immediately after submitting the message (before "Agent is running" appears)
  4. The CLI exits without showing the exit prompt (with a Session was interrupted: interrupted message)

OpenHands Installation

CLI

OpenHands Version

0.48

Model Name

No response

Operating System

None

Logs, Errors, Screenshots, and Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIRelated to the command line interfacebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions