Preserve error codes and surface root cause in agentic RL errors#150
Conversation
- Re-raise exceptions that already carry an error_code instead of wrapping them, so the original code propagates to callers - Add _format_cause() to AgenticRLError, RuntimeErrorWithCode and ValueErrorWithCode so __str__ includes the root cause type and message when the exception was triggered by another error - Let OSSConnectionError escape FunctionComponentModel without being re-wrapped Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request improves exception handling by preventing redundant wrapping of exceptions that already contain an error code, and introduces a _format_cause helper to append root cause details to exception messages. The review feedback correctly identifies that the _format_cause implementation is duplicated across multiple exception classes and risks infinite loops if circular references exist in the exception chain. It is recommended to consolidate this logic into a single, cycle-safe helper method to improve maintainability and robustness.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Agentic RL support cancel async call
- Fix critical race condition: delay disconnect listener until after request body parsing to prevent concurrent receive() calls - Refactor error classes: extract _RootCauseMixin to eliminate duplicated _format_cause and root_cause methods - Extract helper functions to reduce function complexity - Fix pre-commit issues: mypy types, flake8 line length, pylint warnings Addresses PR dashscope#152 review feedback from Gemini Code Assist. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The previous commit (preserve error codes on re-raise) changed register_functions to propagate the inner RegistrationError (error_code=2052) instead of wrapping it in a generic error (error_code=2055). Update the test assertion to check for the original error message and code. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Addresses PR dashscope#150 review feedback: the root_cause property now tracks visited exception IDs to prevent infinite loops if a circular __cause__ chain is accidentally introduced. Also handles empty cause messages gracefully in _format_cause. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Description
[Describe what this PR does and why]
Related Issue: Fixes #[issue_number] or Relates to #[issue_number]
Security Considerations: [Check if API keys or sensitive credentials are exposed in code/logs]
Type of Change
Component(s) Affected
Checklist
Testing
[How to test these changes]
Additional Notes
[Optional: any other context]