Repository navigation
fix(llmchat): mark tool/parsing errors as recoverable in streaming - #3733
Conversation
|
Thanks @kimsehwan96. Clean fix — correctly distinguishes connection-level errors (non-recoverable) from tool/parsing errors (recoverable). The approach of letting |
ConnectionError and TimeoutError are now re-raised directly from chat_events() so the router can handle them with their original type. Remaining RuntimeErrors (tool failures, parsing errors, model config issues) are marked recoverable so the frontend keeps the session alive instead of forcing a reconnect. Signed-off-by: kimsehwan96 <[email protected]>
…opagation tests Verify that token_streamer sets the correct recoverable value for each error type (RuntimeError→true, ConnectionError→false, TimeoutError→true, generic→false). Add service-level tests confirming ConnectionError and TimeoutError propagate from chat_events() without being wrapped as RuntimeError. Signed-off-by: Mihai Criveti <[email protected]>
Flake8 DAR401 flagged the missing exception types in the Raises section after the new except clause was added. Signed-off-by: Mihai Criveti <[email protected]>
…RuntimeError Introduce ChatProcessingError(RuntimeError) for tool/parsing/model failures that leave the session intact. The router now catches ChatProcessingError as recoverable and plain RuntimeError (e.g. "not initialized") as non-recoverable, preventing a race where a concurrent disconnect could leave the frontend on a dead session. Signed-off-by: Mihai Criveti <[email protected]>
df652c5 to
be55779
Compare
|
Thanks for this fix @kimsehwan96 — the core observation that I rebased onto Changes made during review
All tests pass (255 passed, 1 skipped). |
crivetimihai
left a comment
There was a problem hiding this comment.
LGTM — the fix correctly separates recoverable (tool/parsing/model) errors from non-recoverable (session/connection) errors in the streaming path. Added ChatProcessingError to close the race condition gap, plus full differential test coverage. Ready to merge.
…BM#3733) * fix(llmchat): mark tool/parsing errors as recoverable in streaming ConnectionError and TimeoutError are now re-raised directly from chat_events() so the router can handle them with their original type. Remaining RuntimeErrors (tool failures, parsing errors, model config issues) are marked recoverable so the frontend keeps the session alive instead of forcing a reconnect. Signed-off-by: kimsehwan96 <[email protected]> * test(llmchat): assert recoverable flag and add service-layer error propagation tests Verify that token_streamer sets the correct recoverable value for each error type (RuntimeError→true, ConnectionError→false, TimeoutError→true, generic→false). Add service-level tests confirming ConnectionError and TimeoutError propagate from chat_events() without being wrapped as RuntimeError. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): add ConnectionError/TimeoutError to chat_events docstring Flake8 DAR401 flagged the missing exception types in the Raises section after the new except clause was added. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): distinguish recoverable ChatProcessingError from fatal RuntimeError Introduce ChatProcessingError(RuntimeError) for tool/parsing/model failures that leave the session intact. The router now catches ChatProcessingError as recoverable and plain RuntimeError (e.g. "not initialized") as non-recoverable, preventing a race where a concurrent disconnect could leave the frontend on a dead session. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: kimsehwan96 <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
…3733) * fix(llmchat): mark tool/parsing errors as recoverable in streaming ConnectionError and TimeoutError are now re-raised directly from chat_events() so the router can handle them with their original type. Remaining RuntimeErrors (tool failures, parsing errors, model config issues) are marked recoverable so the frontend keeps the session alive instead of forcing a reconnect. Signed-off-by: kimsehwan96 <[email protected]> * test(llmchat): assert recoverable flag and add service-layer error propagation tests Verify that token_streamer sets the correct recoverable value for each error type (RuntimeError→true, ConnectionError→false, TimeoutError→true, generic→false). Add service-level tests confirming ConnectionError and TimeoutError propagate from chat_events() without being wrapped as RuntimeError. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): add ConnectionError/TimeoutError to chat_events docstring Flake8 DAR401 flagged the missing exception types in the Raises section after the new except clause was added. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): distinguish recoverable ChatProcessingError from fatal RuntimeError Introduce ChatProcessingError(RuntimeError) for tool/parsing/model failures that leave the session intact. The router now catches ChatProcessingError as recoverable and plain RuntimeError (e.g. "not initialized") as non-recoverable, preventing a race where a concurrent disconnect could leave the frontend on a dead session. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: kimsehwan96 <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
…BM#3733) * fix(llmchat): mark tool/parsing errors as recoverable in streaming ConnectionError and TimeoutError are now re-raised directly from chat_events() so the router can handle them with their original type. Remaining RuntimeErrors (tool failures, parsing errors, model config issues) are marked recoverable so the frontend keeps the session alive instead of forcing a reconnect. Signed-off-by: kimsehwan96 <[email protected]> * test(llmchat): assert recoverable flag and add service-layer error propagation tests Verify that token_streamer sets the correct recoverable value for each error type (RuntimeError→true, ConnectionError→false, TimeoutError→true, generic→false). Add service-level tests confirming ConnectionError and TimeoutError propagate from chat_events() without being wrapped as RuntimeError. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): add ConnectionError/TimeoutError to chat_events docstring Flake8 DAR401 flagged the missing exception types in the Raises section after the new except clause was added. Signed-off-by: Mihai Criveti <[email protected]> * fix(llmchat): distinguish recoverable ChatProcessingError from fatal RuntimeError Introduce ChatProcessingError(RuntimeError) for tool/parsing/model failures that leave the session intact. The router now catches ChatProcessingError as recoverable and plain RuntimeError (e.g. "not initialized") as non-recoverable, preventing a race where a concurrent disconnect could leave the frontend on a dead session. Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: kimsehwan96 <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
🔗 Related Issue
Close: #3763
📝 Summary
When a tool invocation fails or a response parsing error occurs during LLM Chat streaming, the frontend disconnects the session and asks the user to reconnect. This happens because
chat_events()wraps all exceptions — includingConnectionErrorandTimeoutError— into a singleRuntimeError, which the router always marks asrecoverable: False.This PR lets
ConnectionError/TimeoutErrorpropagate with their original type so the router's existing handlers catch them correctly. The remainingRuntimeErrors (tool failures, parsing errors, model issues) are now markedrecoverable: Truesince the session is still valid.🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
Before: any error during streaming →
RuntimeError("Chat processing error: ...")→recoverable: False→ session killedAfter:
ConnectionError/TimeoutError→ re-raised as-is → caught by existing router handlers.Everything else →
RuntimeError→recoverable: True→ error shown but session stays alive.