Long responses appear multiple times in the terminal window
Long responses from openkb chat and openkb query appear repeatedly in terminal scrollback.
The problem reproduces in both iTerm2 and the VS Code integrated terminal on macOS. I have verified the persisted chat JSON logs and they contain (correctly) the response only once, confirming that the model output and stored session are correct and that the duplication is introduced by terminal rendering (see verification screenshots below).
jq -r '.assistant_texts[]' .openkb/chats/<session-id>.json
How to reproduce
- Open a terminal with a relatively short viewport e.g. on a laptop.
- Run:
openkb chat OR openkb query "any query which would lead to a longer response..."
- Generate a response substantially longer than the terminal viewport.
- After the response completes, scroll upward through the terminal history.
Reason for the current behaviour
OpenKB creates its Rich live display with:
# In agent/chat.py and agent/query.py
Live(console=console, vertical_overflow="visible")
but Rich already documents that a live display cannot be properly cleared when vertical_overflow="visible" is used:
"visible" will allow the whole renderable to be shown. Note that the display cannot be properly cleared in this mode.
Proposed fixed (verified by me locally)
I changed the overflow mode to "ellipsis" which fixes the scrollback / redraw issue in both terminals. (Ellipsis is default, I just made it explicit)
Actual behavior
I was able to reprodice this behavior in:
- iTerm2
- VS Code integrated terminal
Screenshot: Current visible behavior
Notice the repeated "G-Eval" lines
In VSCode Terminal:
In iTerm:
Fix
If this fix is acceptable, I'm happy to raise a PR: Use Rich’s bounded "ellipsis" overflow behavior:
diff --git a/openkb/agent/chat.py b/openkb/agent/chat.py
@@
- lv = Live(console=console, vertical_overflow="visible")
+ lv = Live(console=console, vertical_overflow="ellipsis")
diff --git a/openkb/agent/query.py b/openkb/agent/query.py
@@
- lv = Live(console=console, vertical_overflow="visible")
+ lv = Live(console=console, vertical_overflow="ellipsis")
Screenshot: Fixed ellipsis behavior
Environment
- OpenKB:
0.4.5
- Python:
3.14.7
- Rich:
15.0.0
- macOS:
26.6.2 (25G83)
- Architecture: Apple Silicon /
arm64
- iTerm2:
3.7.2
- Visual Studio Code:
1.138.0
Long responses appear multiple times in the terminal window
Long responses from
openkb chatandopenkb queryappear repeatedly in terminal scrollback.The problem reproduces in both iTerm2 and the VS Code integrated terminal on macOS. I have verified the persisted chat JSON logs and they contain (correctly) the response only once, confirming that the model output and stored session are correct and that the duplication is introduced by terminal rendering (see verification screenshots below).
How to reproduce
openkb chatORopenkb query "any query which would lead to a longer response..."Reason for the current behaviour
OpenKB creates its Rich live display with:
but Rich already documents that a live display cannot be properly cleared when
vertical_overflow="visible"is used:Proposed fixed (verified by me locally)
I changed the overflow mode to
"ellipsis"which fixes the scrollback / redraw issue in both terminals. (Ellipsis is default, I just made it explicit)Actual behavior
I was able to reprodice this behavior in:
Screenshot: Current
visiblebehaviorIn VSCode Terminal:
In iTerm:
Fix
If this fix is acceptable, I'm happy to raise a PR: Use Rich’s bounded
"ellipsis"overflow behavior:Screenshot: Fixed
ellipsisbehaviorEnvironment
0.4.53.14.715.0.026.6.2(25G83)arm643.7.21.138.0