Skip to content

Conversation

bharath03-a
Copy link

@bharath03-a bharath03-a commented Sep 27, 2025

Description

Implements a retry mechanism to handle transient API errors like 503 "The model is overloaded", 429 rate limits, and timeouts. This prevents the loss of all processing work when encountering temporary service issues.

Changes Involved

  • Multi-level retry strategies
  • Exponential backoff with jitter to prevent thundering herd problems
  • Configurable retry parameters for user customization
  • Fallback mechanism: batch failures fall back to individual chunk processing
  • Comprehensive error detection for transient vs permanent errors

API Changes

New optional parameters in extract() function:

  • retry_transient_errors: bool = True
  • max_retries: int = 3
  • retry_initial_delay: float = 1.0
  • retry_backoff_factor: float = 2.0
  • retry_max_delay: float = 60.0

Files Changed

  • langextract/retry_utils.py - New retry utility module
  • langextract/extraction.py - Added retry parameters to extract()
  • langextract/annotation.py - Integrated retry logic in processing
  • langextract/providers/gemini.py - Applied retry decorator
  • tests/retry_utils_test.py - New test suite
  • tests/annotation_test.py - Added retry integration tests

How Has This Been Tested?

  • Unit tests for retry utility functions
  • Integration tests for retry parameter passing
  • Error detection and retry behavior validation
  • Manual testing with 503 error scenarios

Checklist

  • Code follows the project's style guidelines
  • Self-review of the code has been performed
  • Tests have been added that prove the fix is effective
  • New and existing unit tests pass locally
  • Changes are backward compatible

Fixes #240

@github-actions github-actions bot added the size/L Pull request with 600-1000 lines changed label Sep 27, 2025
Copy link

Infrastructure File Protection

This PR modifies protected infrastructure files:

  • .github/workflows/ci.yaml (12 changes)
  • .github/workflows/validate_pr_template.yaml (6 changes)

Only repository maintainers are allowed to modify infrastructure files (including .github/, build configuration, and repository documentation).

Note: If these are only formatting changes, please:

  1. Revert changes to .github/ files
  2. Use ./autoformat.sh to format only source code directories
  3. Avoid running formatters on infrastructure files

If structural changes are necessary:

  1. Open an issue describing the needed infrastructure changes
  2. A maintainer will review and implement the changes if approved

For more information, see our Contributing Guidelines.

@bharath03-a bharath03-a reopened this Sep 27, 2025
@bharath03-a bharath03-a force-pushed the retry_feature_langextract branch from ec7be58 to 7cd5951 Compare September 27, 2025 02:19
@bharath03-a
Copy link
Author

Infrastructure File Protection

This PR modifies protected infrastructure files:

  • .github/workflows/ci.yaml (12 changes)
  • .github/workflows/validate_pr_template.yaml (6 changes)

Only repository maintainers are allowed to modify infrastructure files (including .github/, build configuration, and repository documentation).

Note: If these are only formatting changes, please:

  1. Revert changes to .github/ files
  2. Use ./autoformat.sh to format only source code directories
  3. Avoid running formatters on infrastructure files

If structural changes are necessary:

  1. Open an issue describing the needed infrastructure changes
  2. A maintainer will review and implement the changes if approved

For more information, see our Contributing Guidelines.

Fixed the issues!

@bharath03-a bharath03-a reopened this Sep 27, 2025
Copy link

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

@bharath03-a bharath03-a reopened this Sep 27, 2025
@github-actions github-actions bot added size/XL Pull request with over 1000 lines changed - too large and removed size/L Pull request with 600-1000 lines changed labels Sep 27, 2025
Copy link

github-actions bot commented Oct 4, 2025

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

1 similar comment
Copy link

⚠️ Branch Update Required

Your branch is 1 commits behind main. Please update your branch to ensure CI checks run with the latest code:

git fetch origin main
git merge origin/main
git push

Note: Enable "Allow edits by maintainers" to allow automatic updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Pull request with over 1000 lines changed - too large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

langextract chunking does not recover from 503 error "The model is overloaded"

1 participant