fix: handle CR in agent yes/no prompts#215
Open
arsis-dev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ds4-agentnow treats carriage return as a valid line terminator in its yes/no prompts.This fixes an interactive exit path where a terminal could send
\rafter replying to:With the old
fgets()-based parser, that response could remain visually stuck asy^Minstead 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\nor\ras the end of the response. EOF / Ctrl+D still declines the prompt.Validation
Machine/backend: macOS on Apple M5 Max, Metal backend, default
ds4_testmodel (ds4flash.gguf).Commands run:
git diff --check -- ds4_agent.c ./ds4_test --server make clean make ds4-agent make testResults:
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, andserverall OK).