Did you check docs and existing issues?
Python version (python --version)
Python 3.13.2
Operating system/version
Tahoe 26.3
NeMo-Guardrails version (if you must use a specific version and not the latest
0.21
Describe the bug
Two bugs discovered by Greptile in #1766 which were out-of-scope for that PR. Capturing here to be fixed later. Quoting from the comment:
Two P2 issues exist in the CLI streaming path worth addressing before or after merge.
Empty assistant message appended to history on streaming error (cli/chat.py lines 106-107): when a streaming error chunk is received and the loop breaks, bot_message_list is empty; the resulting {"role": "assistant", "content": ""} is unconditionally appended to history at line 181, corrupting subsequent turns with a blank assistant message.
Fragile error-chunk detection in CLI (cli/chat.py line 94): errors are identified via chunk.startswith('{"error"') — a raw string prefix check — while the server correctly uses ChunkError.model_validate_json(). Any whitespace or key-ordering change in the emitted JSON would silently pass the error through as normal content in the CLI.
Steps To Reproduce
- Run
nemoguardrails chat application with streaming enabled.
- Insert streaming error chunk into App LLM response or with an "error" that doesn't match the expected format.
Expected Behavior
Handle error chunks gracefully and not corrupt conversation turns.
Actual Behavior
Corrupted conversation turns and potential missed error chunk responses
Did you check docs and existing issues?
Python version (python --version)
Python 3.13.2
Operating system/version
Tahoe 26.3
NeMo-Guardrails version (if you must use a specific version and not the latest
0.21
Describe the bug
Two bugs discovered by Greptile in #1766 which were out-of-scope for that PR. Capturing here to be fixed later. Quoting from the comment:
Two P2 issues exist in the CLI streaming path worth addressing before or after merge.
Empty assistant message appended to history on streaming error (cli/chat.py lines 106-107): when a streaming error chunk is received and the loop breaks, bot_message_list is empty; the resulting {"role": "assistant", "content": ""} is unconditionally appended to history at line 181, corrupting subsequent turns with a blank assistant message.
Fragile error-chunk detection in CLI (cli/chat.py line 94): errors are identified via chunk.startswith('{"error"') — a raw string prefix check — while the server correctly uses ChunkError.model_validate_json(). Any whitespace or key-ordering change in the emitted JSON would silently pass the error through as normal content in the CLI.
Steps To Reproduce
nemoguardrails chatapplication with streaming enabled.Expected Behavior
Handle error chunks gracefully and not corrupt conversation turns.
Actual Behavior
Corrupted conversation turns and potential missed error chunk responses