Skip to content

fix: handle CR in agent yes/no prompts#215

Open
arsis-dev wants to merge 1 commit into
antirez:mainfrom
arsis-dev:fix-agent-yes-no-cr
Open

fix: handle CR in agent yes/no prompts#215
arsis-dev wants to merge 1 commit into
antirez:mainfrom
arsis-dev:fix-agent-yes-no-cr

Conversation

@arsis-dev
Copy link
Copy Markdown

@arsis-dev arsis-dev commented May 21, 2026

Summary

ds4-agent now treats carriage return as a valid line terminator in its yes/no prompts.

This fixes an interactive exit path where a terminal could send \r after replying to:

Save current session? (y/n)

With the old fgets()-based parser, that response could remain visually stuck as y^M instead of being accepted cleanly.

Root cause

The prompt helper only parsed complete lines read by fgets(), which assumes newline-delimited input. Some terminal paths can deliver carriage return for Enter in this restored-terminal prompt path.

Change

agent_prompt_yes_no() now reads one byte at a time, records the first non-space answer, and accepts either \n or \r as the end of the response. EOF / Ctrl+D still declines the prompt.

Validation

Machine/backend: macOS on Apple M5 Max, Metal backend, default ds4_test model (ds4flash.gguf).

Commands run:

git diff --check -- ds4_agent.c
./ds4_test --server
make clean
make ds4-agent
make test

Results:

  • git diff --check -- ds4_agent.c: passed.
  • ./ds4_test --server: passed.
  • make clean && make ds4-agent: passed.
  • make test: passed (long-context, tool-call-quality, logprob-vectors, metal-kernels, and server all OK).

@arsis-dev arsis-dev marked this pull request as ready for review May 21, 2026 13:34
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