Trial retry backoff sleeps while holding the global concurrency slot; one rate-limited agent can stall a multi-agent job
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend, distributed-systems
Research direction
Start with TrialQueue._run_trial and _execute_trial_with_retries in src/harbor/trial/queue.py, then trace how job_plan.py schedules trials and uses the semaphore. Check the existing retry tests before changing the flow. Done when retry backoff no longer blocks healthy trials from using global concurrency slots and the tests cover this behavior.
Written by the indexing model from the issue text.
Description
Problem
TrialQueue._run_trial acquires the job-wide semaphore and then runs _execute_trial_with_retries inside it
(src/harbor/trial/queue.py, _run_trial / _execute_trial_with_retries). The retry backoff
(await asyncio.sleep(delay_sec)) therefore runs while the trial still holds one of n_concurrent_trials slots.
That is cheap with the default backoff (1-60 s). It becomes a problem when the backoff is long enough to outlast a
provider or subscription quota window, which is the reason to configure RetryConfig.min_wait_sec/max_wait_sec
for ApiRateLimitError at all. Quota windows of hours are common for subscription plans. In a job with several
agents (JobConfig.agents with per-agent n_concurrent / concurrency_group), when one provider's quota runs out:
- its trials fail fast with
ApiRateLimitErrorand go to sleep formin_wait_sec * multiplier^attempt, each holding
a global slot; - trials are interleaved by agent (
job_plan.py), so as other agents' trials finish, more of the exhausted agent's
trials start, fail and sleep; - eventually all
n_concurrent_trialsslots are held by sleeping trials and the agents whose quota is fine make no
progress until the backoff ends.
The per-agent caps (AgentConfig.n_concurrent) do not help: they gate only the agent.run() phase via
AGENT_START/AGENT_END hooks. Environment start, agent setup and the retry sleep all sit under the global semaphore.
Minimal repro
# job.yaml
n_concurrent_trials: 4
retry: {max_retries: 3, include_exceptions: [ApiRateLimitError], min_wait_sec: 600, wait_multiplier: 2, max_wait_sec: 3600}
agents:
- {name: agent-a, model_name: provider-a/model, n_concurrent: 2} # quota exhausted -> ApiRateLimitError
- {name: agent-b, model_name: provider-b/model, n_concurrent: 2} # healthy
Once agent-a's quota runs out, the healthy agent-b trials make no progress until agent-a's backoff (10+ minutes)
ends. The same happens with any agent that raises a retryable error quickly.
Proposed change
Release the global slot during the backoff and acquire it again before the next attempt:
async def _run_trial(self, trial_config):
for attempt in range(self._retry_config.max_retries + 1):
async with self._semaphore:
result, delay = await self._run_attempt(trial_config, attempt) # returns (result, None) when final
if delay is None:
return result
await asyncio.sleep(delay) # outside the semaphore
The attempt directory cleanup stays where it is. Retried trials can be queued behind fresh ones; if that ordering
matters, a priority queue or an "acquire before fresh trials" flag can keep it.
Optional follow-up, possibly a separate issue: let a rate-limit failure pause the agent's concurrency pool
(concurrency_key) for the backoff instead of each trial backing off on its own. Then one quota reset is waited for
once, not N times. #1664 covers LiteLLM-level 429 retries; this issue is about trial-level retries in TrialQueue.
Version: harbor 0.27.0 (unchanged in 0.27.1.dev202612011755).
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 1.9k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 156
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from harbor-framework/harbor
-
Trial runs the agent's `populate_context_post_run` on the event loop, so trials that end together stall the orchestrator for secondsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
harbor-framework/harbor#4652 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
harbor-framework/harbor#4494 · 1 comment ·
Maintainers usually reply within 1 day
-
step workdir upload resets the work folder's owner and permissions in ModalPossibly taken @Sauvi72 claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
harbor-framework/harbor#4487 · 3 comments ·
Maintainers usually reply within 1 day
-
Docker: verifier log mounts are chmod 777 (no sticky), so rewardkit sandboxed graders die before writing a rewardPossibly taken @yuyz-cyber claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
harbor-framework/harbor#4469 · 1 comment ·
Maintainers usually reply within 1 day
-
Compare and Pareto hide total token usage when the cached token count is missingPossibly taken @Aafimalek claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
harbor-framework/harbor#4448 ·
Maintainers usually reply within 1 day
All issues in harbor-framework/harbor
Similar issues
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePossibly taken @abdulwaarith0 claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
MakazhanAlpamys/Soup#3690 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug data-types native-format
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ClickHouse/clickhouse-connect#1320 ·
Maintainers usually reply within 1 day
-
accepted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
future-agi/future-agi#6392 ·
Maintainers usually reply within 1 day