Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 22, 2025

Fixes a bug where rate limiting would be silently disabled in edge cases when provider state is unavailable.

Problem

In Task.ts, the rate limit is read from the provider state in two locations:

  • Line 3643 in attemptApiRequest
  • Line 3974 in backoffAndAnnounce

When state is undefined/null (provider reference lost or getState() fails), the rate limit defaults to 0, effectively disabling rate limiting.

Solution

Use the task's stored configuration as a fallback:

const rateLimit = (apiConfiguration ?? this.apiConfiguration)?.rateLimitSeconds || 0

This ensures:

  • The most up-to-date configuration from state is preferred
  • If state is unavailable, the task's stored configuration is used as fallback
  • Rate limiting is only disabled if neither source has a configuration

Impact

This bug rarely manifests since getState() usually succeeds. However, in edge cases where the provider reference is temporarily unavailable, users' configured rate limits would be silently ignored, potentially causing API rate limit errors.

Testing

  • All existing tests pass (34 passed)
  • Linting passes
  • Type checking passes

View task on Roo Code Cloud


Important

Fixes rate limiting bug in Task.ts by using task's stored configuration as fallback when provider state is unavailable.

  • Behavior:
    • Fixes bug in Task.ts where rate limiting was disabled when provider state was unavailable.
    • Uses task's stored configuration as fallback for rate limit in attemptApiRequest and backoffAndAnnounce.
    • Rate limiting is only disabled if neither source provides a configuration.
  • Impact:
    • Prevents silent disabling of rate limits in edge cases, reducing potential API rate limit errors.
  • Testing:
    • All existing tests pass (34 passed).
    • Linting and type checking pass.

This description was created by Ellipsis for f3caed7. You can customize this summary. It will automatically update as commits are pushed.

When provider state is unavailable (state is undefined/null), fall back to the task's stored apiConfiguration for rate limiting instead of defaulting to 0.

This prevents rate limiting from being silently disabled in edge cases where getState() fails or provider reference is temporarily lost.

Changes:
- Line 3643 (attemptApiRequest): Use (apiConfiguration ?? this.apiConfiguration)
- Line 3974 (backoffAndAnnounce): Use (state?.apiConfiguration ?? this.apiConfiguration)

Both locations now follow the same pattern:
1. Prefer the most up-to-date config from provider state
2. Fall back to task's stored config if state unavailable
3. Only default to 0 if neither source has a config
@roomote
Copy link
Contributor Author

roomote bot commented Dec 22, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The changes correctly implement a fallback mechanism for rate limiting when provider state is unavailable:

  • Both modifications follow the same consistent pattern using nullish coalescing (??)
  • this.apiConfiguration is guaranteed to be defined (set in constructor from required parameter)
  • The fix preserves existing behavior when state is available while providing a sensible fallback

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@brunobergher brunobergher marked this pull request as ready for review December 22, 2025 13:43
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Dec 22, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Dec 22, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The changes correctly implement a fallback mechanism for rate limiting when provider state is unavailable:

  • Both modifications follow a consistent pattern using nullish coalescing (??)
  • this.apiConfiguration is guaranteed to be defined (set in constructor from required parameter)
  • The fix preserves existing behavior when state is available while providing a sensible fallback

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 22, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 22, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

This seems fine, but why do we ever use apiConfiguration from state? Should we not just use this.apiConfiguration everywhere?

@daniel-lxs
Copy link
Member

@mrubens
I agree, in that case do we need apiConfiguration to be in the state at all?

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

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

5 participants