Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the retry mechanism by simplifying the implementation and reorganizing the module location. The main changes consolidate the retry logic from a decorator-based approach to a simpler function wrapper approach, while moving the retry module into the llm subdirectory to better reflect its primary usage context.
Changes:
- Removed the
asyncRetrydecorator function and simplifiedwrapWithRetryto directly wrap functions without decorator indirection - Moved the retry module from
packages/ema/src/retry.tstopackages/ema/src/llm/retry.ts - Updated all import paths across
openai_client.ts,google_client.ts,config.ts, andagent.tsto reference the new location
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ema/src/llm/retry.ts | Removed decorator pattern, simplified wrapWithRetry to directly wrap functions, and added validation for max_retries |
| packages/ema/src/llm/openai_client.ts | Updated import path from ../retry to ./retry |
| packages/ema/src/llm/google_client.ts | Updated import path from ../retry to ./retry |
| packages/ema/src/config.ts | Updated import and export paths from ./retry to ./llm/retry |
| packages/ema/src/agent.ts | Updated import path from ./retry to ./llm/retry |
Comments suppressed due to low confidence (2)
packages/ema/src/llm/retry.ts:99
- The validation
if (config.max_retries <= 0)is overly restrictive. Settingmax_retriesto 0 is a valid use case meaning "no retries, just one attempt". The original code would have supported this (the loop runs withattempt = 0and throws on first failure). This validation breaks backward compatibility for users who might want to disable retries by settingmax_retries: 0while keepingenabled: true. Consider either removing this validation or changing it toif (config.max_retries < 0)to only reject negative values.
packages/ema/src/llm/retry.ts:123 - The error messages no longer include the function name (previously used
propertyKeyfrom the decorator). This makes debugging more difficult as it's harder to identify which function's retry failed. Consider adding an optionalfunctionNameparameter towrapWithRetrythat can be included in error messages, or document that users should provide this context in theironRetrycallback if needed for debugging.
Disviel
approved these changes
Mar 1, 2026
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.
This PR refactors the retry mechanism by simplifying the implementation and reorganizing the module location. The main changes consolidate the retry logic from a decorator-based approach to a simpler function wrapper approach, while moving the retry module into the
llmsubdirectory to better reflect its primary usage context.