Skip to content

Agent: fix incorrect waiting logic in the case when acquiring fails#10193

Merged
SpecLad merged 3 commits intocvat-ai:developfrom
SpecLad:agent-acquire-delay
Jan 16, 2026
Merged

Agent: fix incorrect waiting logic in the case when acquiring fails#10193
SpecLad merged 3 commits intocvat-ai:developfrom
SpecLad:agent-acquire-delay

Conversation

@SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Jan 16, 2026

Motivation and context

The usage of _wait_between_polls here is incorrect. It waits for an AR to become available, but if we're in _poll_for_ar, that means an AR is already (potentially) available, and we just need to acquire it. If acquiring fails, we just need to wait a little for the server to recover, and then try again.

_wait_between_polls can wait for wildly inappropriate amounts:

  • If there's already another pending AR, then it will return immediately, so _poll_for_ar will pound the server with acquire requests.

  • If there is no pending AR, then it can wait for up to 10 minutes, which is likely way more than the server would take to recover.

So, remove _wait_between_polls here and replace it with a short sleep with exponential backoff.

How has this been tested?

Manual testing.

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • [ ] I have updated the documentation accordingly
  • [ ] I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

The usage of `_wait_between_polls` here is incorrect. It waits for an AR
to become available, but if we're in `_poll_for_ar`, that means an AR is
already (potentially) available, and we just need to acquire it. If acquiring
fails, we just need to wait a little for the server to recover, and then
try again.

`_wait_between_polls` can wait for wildly inappropriate amounts:

* If there's already another pending AR, then it will return immediately,
  so `_poll_for_ar` will pound the server with acquire requests.

* If there is no pending AR, then it can wait for up to 10 minutes, which
  is likely way more than the server would take to recover.

So, remove `_wait_between_polls` here and replace it with a short sleep
with exponential backoff.
@SpecLad SpecLad marked this pull request as ready for review January 16, 2026 16:09
@SpecLad SpecLad requested a review from nmanovic as a code owner January 16, 2026 16:09
@sonarqubecloud
Copy link

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.84%. Comparing base (e5ce0be) to head (c531578).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10193      +/-   ##
===========================================
- Coverage    82.69%   75.84%   -6.86%     
===========================================
  Files          481      430      -51     
  Lines        49520    46496    -3024     
  Branches      4166     4166              
===========================================
- Hits         40949    35263    -5686     
- Misses        8571    11233    +2662     
Components Coverage Δ
cvat-ui 77.58% <ø> (-0.05%) ⬇️
cvat-server 74.36% <ø> (-12.17%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SpecLad SpecLad merged commit b261a01 into cvat-ai:develop Jan 16, 2026
49 checks passed
@SpecLad SpecLad deleted the agent-acquire-delay branch January 16, 2026 16:53
@cvat-bot cvat-bot bot mentioned this pull request Jan 19, 2026
prathamesh-patil-5090 pushed a commit to prathamesh-patil-5090/cvat that referenced this pull request Jan 19, 2026
…vat-ai#10193)

The usage of `_wait_between_polls` here is incorrect. It waits for an AR
to become available, but if we're in `_poll_for_ar`, that means an AR is
already (potentially) available, and we just need to acquire it. If
acquiring fails, we just need to wait a little for the server to
recover, and then try again.

`_wait_between_polls` can wait for wildly inappropriate amounts:

* If there's already another pending AR, then it will return
immediately, so `_poll_for_ar` will pound the server with acquire
requests.

* If there is no pending AR, then it can wait for up to 10 minutes,
which is likely way more than the server would take to recover.

So, remove `_wait_between_polls` here and replace it with a short sleep
with exponential backoff.
zoe-seo pushed a commit to AutoLabeling-dotdot/AutoLabelingTool that referenced this pull request Jan 22, 2026
…vat-ai#10193)

The usage of `_wait_between_polls` here is incorrect. It waits for an AR
to become available, but if we're in `_poll_for_ar`, that means an AR is
already (potentially) available, and we just need to acquire it. If
acquiring fails, we just need to wait a little for the server to
recover, and then try again.

`_wait_between_polls` can wait for wildly inappropriate amounts:

* If there's already another pending AR, then it will return
immediately, so `_poll_for_ar` will pound the server with acquire
requests.

* If there is no pending AR, then it can wait for up to 10 minutes,
which is likely way more than the server would take to recover.

So, remove `_wait_between_polls` here and replace it with a short sleep
with exponential backoff.
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.

2 participants