Skip to content

cli: -no-cnv means one turn, and a non-TTY stdin ends the interactive loop (engine#561) - #145

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/cli-no-cnv-guard
Oct 25, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/cli-no-cnv-guard

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Fixes engine#561. llama-cli ... -no-cnv -p "..." -n 32 </dev/null ran the interactive loop anyway and printed > into its output for as long as the process lived — 9.4 GB and 2 × 20 GB were written in the field.

Two causes, both fixed:

  1. -no-cnv / --no-conversation only switched the conversation template off. It now also sets single_turn (what -st does), which is what the flag reads as and what people already expect of it.
  2. The interactive loop read a redirected/closed stdin as an endless empty line. With stdin not a TTY, the first empty read now ends the session instead of looping (POSIX isatty / _isatty on Windows).

The third part of the report — unknown flags silently falling into interactive mode — does not reproduce on this base: common/arg.cpp already refuses them (error: invalid argument: --definitely-not-a-flag, exit 1), so no change was needed there; it is covered by the verification below.

Verified (llama-cli built from this branch, Qwen3-0.6B Q4_K_M, </dev/null, -n 8)

run before after
-no-cnv -p "Say hi." 169,516,021 bytes of > in 20 s, killed by timeout 1,034 bytes, exit 0
-p "Say hi." (no -no-cnv) same endless loop 1,034 bytes, exit 0
--definitely-not-a-flag exit 1, error: invalid argument unchanged

Notes

  • -no-cnv now behaves like -st; a scripted single-shot run that previously survived only because it was killed early behaves the same, and one that relied on the loop (none can, it never consumed input) is not affected.
  • Nothing in the engine's HRX paths is touched: common/arg.cpp (the -cnv/-no-cnv handler) and tools/cli/cli-context.cpp (the loop's stdin read).

🤖 Generated with Claude Code

…e#561)

`llama-cli ... -no-cnv -p ... </dev/null` ran the interactive loop anyway, printing "> " into its
output for as long as it lived: 169 MB in 20 s here, 9.4 GB and 2 x 20 GB in the field. Two causes,
both fixed here:

- `-no-cnv` / `--no-conversation` only switched the conversation template off; it did not say "one turn
  and exit". It now sets single_turn, which is what `-st` does, so the meaning people already expect
  from the flag is the behaviour.
- the interactive loop read from a redirected or closed stdin and got an empty line forever. With stdin
  not a TTY the first empty read now ends the session instead of spinning.

An unknown flag was already refused (`error: invalid argument: ...`, exit 1) and stays so; it is the
third part of the report and needed no change.

Verified with llama-cli built from this tree, Qwen3-0.6B, `</dev/null`, `-n 8`:
  -no-cnv before: 169,516,021 bytes of "> " in 20 s (killed by timeout)
  -no-cnv after : 1,034 bytes, exit 0
  no -no-cnv   : 1,034 bytes, exit 0 (previously the same loop)
  --unknown    : exit 1, "error: invalid argument: --definitely-not-a-flag"

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

1 participant