Skip to content

Preserve error codes and surface root cause in agentic RL errors#150

Merged
lzsweb merged 13 commits into
dashscope:mainfrom
luozirong2025:main
Jun 23, 2026
Merged

Preserve error codes and surface root cause in agentic RL errors#150
lzsweb merged 13 commits into
dashscope:mainfrom
luozirong2025:main

Conversation

@luozirong2025

Copy link
Copy Markdown
Contributor
  • 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

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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Model
  • Application
  • Common
  • Documentation
  • Tests
  • CI/CD

Checklist

  • Pre-commit hooks pass
  • Tests pass locally
  • Documentation updated (if needed)
  • Ready for review

Testing

[How to test these changes]

Additional Notes

[Optional: any other context]

zirongluo and others added 7 commits June 8, 2026 12:09
- 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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread dashscope/finetune/reinforcement/common/errors.py Outdated
Comment thread dashscope/finetune/reinforcement/common/errors.py Outdated
Comment thread dashscope/finetune/reinforcement/common/errors.py Outdated
luozirong2025 and others added 6 commits June 22, 2026 20:24
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>
@lzsweb lzsweb merged commit 78d8959 into dashscope:main Jun 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants