Skip to content

Implement defense against RateLimitError in CodeAgent#832

Draft
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/3cf86655-c12b-4dc3-b65e-41da8bfd5c50
Draft

Implement defense against RateLimitError in CodeAgent#832
codegen-sh[bot] wants to merge 2 commits intodevelopfrom
gen/3cf86655-c12b-4dc3-b65e-41da8bfd5c50

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented Mar 13, 2025

Description

This PR implements a defense mechanism against RateLimitError in the CodeAgent class. While the underlying LangGraph implementation already has a retry policy for RateLimitError, the CodeAgent's run method needed to be updated to properly handle these errors when they occur.

Changes

  • Added a retry mechanism in the run method of CodeAgent to catch and handle RateLimitError from both Anthropic and OpenAI
  • Implemented exponential backoff with jitter for retries
  • Added proper error messaging to inform users when rate limits are hit
  • Added missing class attributes for SWEBench integration (run_id, instance_id, difficulty)

Testing

The implementation follows the same retry pattern that's already used in the LangGraph implementation, with a maximum of 10 retries, starting with a 30-second delay and exponentially increasing up to a maximum of 1000 seconds between retries.

Fixes CG-11759

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


codegen-bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

1 participant