fix(cli): read piped stdin to EOF instead of the first line (#166) - #167
Merged
Conversation
`cat file | qwisp chat` and `qwisp chat < file` answered using only the first line of the input, with no error and exit 0 — while both the help text and the usage line advertise piping as an input path. Cause: main.swift used readLine(), which returns a single line, for every non-argv prompt. There was no TTY check, so the interactive case (where one line is what the user means) and the piped case shared the same call. Read stdin to EOF when it is not a TTY; keep readLine() interactively, where reading to EOF would block until ^D. Found while building #162's A/B harness: a 126KB (~35K-token) file was ingested as 52 tokens and reported `prompt 52 tok (94 tok/s)` — a healthy-looking run that measured nothing. Same silent-failure class as #151. Gate: test_completion.sh gains a GPU-free regression check (QWISP_FAKE=1 needs no model weights, only the tokenizer the gate already requires). It asserts a strict increase in prompt tokens between one-line and two-line stdin rather than an exact count, so it does not encode the tokenizer's segmentation. Verified RED on the pre-fix binary (both arms 11 tok) and GREEN after (11 < 23). Closes #166 Co-Authored-By: Claude <noreply@anthropic.com>
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
cat file | qwisp chatandqwisp chat < fileanswered using only the first line of the input — no error, no warning, exit 0 — while both the help text and the usage line advertise piping as an input path.main.swiftusedreadLine()(one line) for every non-argv prompt, with no TTY check, so the interactive case (where one line is what the user means) and the piped case shared the same call. Now stdin is read to EOF when it is not a TTY;readLine()stays for the interactive case, where reading to EOF would block until^D.Found while building #162's A/B harness: a 126KB (~35K-token) file was ingested as 52 tokens and reported
prompt 52 tok (94 tok/s) · gen 32 tok (96.4 tok/s)— a completely healthy-looking run that measured nothing. Same silent-failure class as #151.Related issue
Closes #166
Verification
Gates run on a tree containing only this change (the in-progress #162 knob was stashed and both schemes rebuilt first, so the green below is evidence for this commit and not a superset):
scripts/test_raw.sh→ RAWTESTS 98/98 PASSscripts/test_completion.sh→ COMPTEST 97/97 PASS +[stdin] piped multi-line read to EOF: 1-line=11 tok < 2-line=23 tok okscripts/test_bench_batch.sh→ BENCHBATCHTEST PASSThe new regression check is GPU-free (
QWISP_FAKE=1usesFakeBackend: no model weights, only the tokenizer this gate already requires). It asserts a strict increase in prompt tokens between one-line and two-line stdin rather than an exact count, so it does not encode the tokenizer's segmentation.Verified RED before the fix (both arms reported 11 tok on the pre-fix binary) and GREEN after (11 < 23).
Notes for reviewer
qwisp chatwith no argument still takes one line, deliberately.