[Bug]: post_with_retry retries deterministic 4xx responses for ~2.5 minutes before failing

Aperta
#673 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@feiiiiii5 ci sta già lavorando.

Dal 1/11/2026.

  • #674 di @feiiiiii5 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
15/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api

Direzione di ricerca

The retry loop is in post_with_retry in agentlightning/client.py, where raise_for_status() runs inside the try block so the broad except Exception catches 4xx errors. Check the open pull request #674 first, since work is already under way. Done means a 4xx like 401 raises after one request, while 429, 5xx and transport errors still retry; the reproduction uses httpx.MockTransport.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happened?

AgentLightningSyncClient.post_with_retry treats every HTTP error status as retryable. A deterministic client error (401 for a wrong key, 404 for a missing route, 409 for a state conflict, 422 for a payload validation failure) is retried with exponential backoff for about 2.5 minutes (11 attempts, 2+4+8+16+30x6 seconds) and prints 11 POST failed lines before the real error is raised. The trainer/rollout-manager startup and the gateway pause/resume paths all use this method, so a wrong key or bad payload delays startup and the retry noise hides the root cause.

The server's own upstream retry policy only retries {408, 409, 429} plus 5xx (agentlightning/server/proxy.py), and get() never retries status codes, so the client behavior contradicts the rest of the codebase.

Steps to reproduce
import httpx
from agentlightning.client import AgentLightningSyncClient

transport = httpx.MockTransport(lambda request: httpx.Response(401))
client = AgentLightningSyncClient(max_retries=3, transport=transport)
client.post_with_retry("/api/models", json={})  # retries 3 times before raising
Expected behavior

A 4xx response that cannot succeed on retry (except 408/425/429) raises HTTPStatusError after a single request. Transport errors, 5xx, 408, 425 and 429 are still retried.

Actual behavior

Every 4xx is retried for the full backoff window, then the error is raised after ~2.5 minutes and many log lines.

Root cause

agentlightning/client.py calls raise_for_status() inside the try block, so HTTPStatusError for any 4xx is caught by the broad except Exception and retried.

Proposed fix

Add a retryable-status predicate ({408, 425, 429} and 5xx plus transport errors) and fail fast on other statuses, with a regression test that asserts a single request for 400/401/403/404/409/422 and a retry for 503/429.

Lingua principale
Python
Stelle
18.9k
Fork
1.7k
Merge medio
4g 11h
PR unite (30g)
9

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/agent-lightning

Tutte le issue di microsoft/agent-lightning

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.