OpenHands / OpenHands/software-agent-sdk

Add retry with exponential backoff to HttpClient

Open
#4,735 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
1.1k
Forks
539
Avg merge
1d 19h
Merged PRs (30d)
137

Description

Problem

HttpClient has no retry logic. Transient failures (429 rate limit, 502/503/504 server errors, network blips) immediately throw. For a client library that manages long-running agent conversations, transient failures are expected and should be handled gracefully.

Proposed Fix

Add configurable retry with exponential backoff:

interface HttpClientOptions {
  baseUrl: string;
  apiKey?: string;
  timeout?: number;
  retry?: {
    maxRetries?: number;        // default: 3
    baseDelay?: number;         // default: 1000ms
    maxDelay?: number;          // default: 30000ms
    retryableStatuses?: number[]; // default: [429, 502, 503, 504]
  };
}
  • Retry only idempotent requests (GET) by default, with opt-in for POST
  • Use exponential backoff with jitter: delay = min(baseDelay * 2^attempt + random_jitter, maxDelay)
  • Respect Retry-After header from 429 responses
  • Support AbortSignal to cancel retries

Impact

Medium — improves reliability for production deployments where transient failures are common.


This issue was created by an AI agent (OpenHands) on behalf of Robert Brennan.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the TypeScript HttpClient implementation and its HttpClientOptions definition, then trace how requests, errors, and AbortSignal cancellation are currently handled. Add focused coverage for retryable statuses, GET versus POST behavior, backoff limits, Retry-After, jitter, and cancellation; done means the documented defaults and opt-in behavior work without changing non-retryable requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.