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 can send \r after replying to:

Save current session? (y/n)

With the old line-buffered parser, that response could remain visually stuck as y^M instead of being accepted cleanly.

Root cause

The prompt helper parsed complete newline-delimited lines with fgets(). Some terminal paths can deliver carriage return for Enter in this restored-terminal prompt path.

Upstream now also uses the same prompt helper for timed approval prompts, so the fix keeps that timeout behavior while switching the answer parser to read one byte at a time.

Change

agent_prompt_yes_no_ex() now:

  • records the first non-space answer byte;
  • accepts either \n or \r as the end of the response;
  • preserves EOF / Ctrl+D as a negative answer;
  • preserves automatic timeout answers for callers that opt into them.

Validation

Current branch after rebase onto origin/main (ad0209f):

git diff --check origin/main..HEAD
make ds4-agent
make ds4_test
./ds4_test --server

Results:

  • git diff --check origin/main..HEAD: passed.
  • make ds4-agent: passed.
  • make ds4_test: passed.
  • ./ds4_test --server: passed.

Earlier, before this rebase, the same fix was also validated with a full make test from a normal macOS Terminal on Apple M5 Max / Metal backend. The Codex execution context used for this rebase cannot access a Metal device directly, so the current post-rebase verification uses the non-Metal server regression check.

@arsis-dev arsis-dev marked this pull request as ready for review May 21, 2026 13:34
@arsis-dev arsis-dev force-pushed the fix-agent-yes-no-cr branch from 336f9d0 to fb79802 Compare May 23, 2026 13:00
@arsis-dev arsis-dev force-pushed the fix-agent-yes-no-cr branch from fb79802 to 43caaef Compare May 25, 2026 14:59
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