Add exception chaining in Gemini generate_response#1
Closed
aviu16 wants to merge 1 commit intoSkyworkAI:mainfrom
Closed
Add exception chaining in Gemini generate_response#1aviu16 wants to merge 1 commit intoSkyworkAI:mainfrom
aviu16 wants to merge 1 commit intoSkyworkAI:mainfrom
Conversation
When generate_content() raises an exception, it's re-raised as IncompleteIterationError without preserving the original error context. This makes debugging difficult because: - Network errors appear as IncompleteIterationError - Rate limit errors appear as IncompleteIterationError - API errors appear as IncompleteIterationError - Stack traces are lost Added exception chaining with 'from e' to preserve the original exception and stack trace while still raising IncompleteIterationError for retry logic. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Author
|
gonna close this, cant commit to following up on it right now. sorry! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds exception chaining when re-raising exceptions in
generate_responseto preserve original error context for better debugging.Bug Description
In
agent_studio/llm/gemini.py, thegenerate_responsemethod catches all exceptions fromgenerate_content()and re-raises them asIncompleteIterationErrorwithout preserving the original error:Problems:
Lost error context: All exceptions appear as
IncompleteIterationError, making it impossible to distinguish between:Missing stack traces: The original stack trace is discarded, making debugging significantly harder.
Confusing error messages: Error messages don't reflect the actual root cause.
Fix
Added exception chaining with
from e:Benefits
__cause__IncompleteIterationErrorfor the@retrydecoratorExample Error Output
Before (without chaining):
After (with chaining):
Impact
🤖 Generated with Claude Code