Skip to content

Fix clean chat exit on EOF - #1830

Open
pri5h wants to merge 1 commit into
simonw:mainfrom
pri5h:fix-1214-eof-handling
Open

pri5h wants to merge 1 commit into
simonw:mainfrom
pri5h:fix-1214-eof-handling

Conversation

@pri5h

@pri5h pri5h commented Oct 28, 2026 •

Copy link
Copy Markdown

Summary

  • Handle EOF cleanly in chat mode.
  • Prevent unexpected errors when the input stream reaches EOF.
  • Add tests covering EOF handling in chat mode.

Related issue

Closes #1214

Testing

  • Run the relevant chat tests.
  • Confirm the changes pass the test suite.

@connabyss

Copy link
Copy Markdown

Tested on Windows 11 (Python 3.11.6) with llm-echo, using Ctrl+Z then Enter to send EOF:

  • main: prints Aborted!, as described.

  • this PR, click 8.5.0: exits cleanly. 👍

  • this PR, click 8.3.1: crashes as soon as chat starts, before any input:

    File "...\llm\cli.py", line 171, in _run_chat
      prompt = click.termui._readline_prompt(
    AttributeError: module 'click.termui' has no attribute '_readline_prompt'
    

click.termui._readline_prompt is a private helper that first appears in click 8.4.0 (it's not in 8.3.1, 8.3.0, 8.2.1 or 8.1.8). llm's runtime dependency is plain "click" (only the dev group pins >=8.2.0), so anyone with an older click already installed would lose llm chat entirely. Either pinning click>=8.4 in dependencies or avoiding the private helper (for example, calling input() and catching EOFError yourself) would cover it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctrl-d (EOF) should exit cleanly instead of printing "Aborted!"

3 participants