Problem
`on_stdin_read` in src/main.c (the headless `-H` stdio REPL), around
lines 253-262:
```c
if (state->prompt_len < sizeof(state->prompt_line) - 1) {
state->prompt_line[state->prompt_len++] = buf->base[i];
}
```
Once `prompt_len` hits 1023 (buffer is `char prompt_line[1024]`), further
characters before the terminating newline/CR are silently dropped -- no
error, no visible truncation marker. The line that eventually gets
submitted is just quietly shorter than what the user typed, with nothing
indicating truncation happened.
Impact
Low severity/rare in practice (needs a single line over ~1KB pasted into
the headless REPL specifically -- the ncurses TUI has its own separate
input handling), but a bad failure mode when it does happen: a truncated
prompt gets submitted to the model with no indication anything was cut.
Fix direction
Either grow the buffer dynamically, or detect the full condition and
either reject the line with a visible error, or at least print a
truncation notice before submitting.
Found during a manual code review pass on commit 365f3d2.
Problem
`on_stdin_read` in src/main.c (the headless `-H` stdio REPL), around
lines 253-262:
```c
if (state->prompt_len < sizeof(state->prompt_line) - 1) {
state->prompt_line[state->prompt_len++] = buf->base[i];
}
```
Once `prompt_len` hits 1023 (buffer is `char prompt_line[1024]`), further
characters before the terminating newline/CR are silently dropped -- no
error, no visible truncation marker. The line that eventually gets
submitted is just quietly shorter than what the user typed, with nothing
indicating truncation happened.
Impact
Low severity/rare in practice (needs a single line over ~1KB pasted into
the headless REPL specifically -- the ncurses TUI has its own separate
input handling), but a bad failure mode when it does happen: a truncated
prompt gets submitted to the model with no indication anything was cut.
Fix direction
Either grow the buffer dynamically, or detect the full condition and
either reject the line with a visible error, or at least print a
truncation notice before submitting.
Found during a manual code review pass on commit 365f3d2.