Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Feat]: Add RetryTransport for automatic retry with exponential backoff

未关闭
#871 6 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
grpc, python
领域
api, backend

调研方向

查看现有的传输类(JsonRpcTransport、RestTransport、GrpcTransport)以及 TenantTransportDecorator 模式。新的 RetryTransport 必须能够包装任意 ClientTransport。首先检查 SDK 的异常层次结构(A2AClientError、A2AClientTimeoutError),以及它们如何链接 httpx 和 grpc 错误。为 retry predicate 和 on_retry hook 编写测试。确保该实现适用于全部三种传输,并且不会重试领域错误。

由索引模型根据 Issue 内容生成。

描述

component: client
Is your feature request related to a problem? Please describe.

The SDK's transports (JsonRpcTransport, RestTransport, GrpcTransport) raise immediately on transient failures (network errors, timeouts, rate limits, 5xx responses, gRPC UNAVAILABLE/RESOURCE_EXHAUSTED) with no built-in retry mechanism. Every caller has to reimplement the same retry/backoff loop, and to do it correctly they have to inspect __cause__ chains because A2AClientError doesn't expose HTTP status codes or gRPC codes directly.

Describe the solution you'd like

A RetryTransport decorator wrapping any ClientTransport, mirroring the existing TenantTransportDecorator pattern:

inner = JsonRpcTransport(httpx_client=client, agent_card=card)
transport = RetryTransport(base=inner, max_retries=3)

The default predicate retries on:

  • A2AClientTimeoutError (always).
  • A2AClientError chained from httpx.RequestError or httpx.HTTPStatusError(408/429/502/503/504).
  • A2AClientError chained from grpc.aio.AioRpcError(UNAVAILABLE/RESOURCE_EXHAUSTED).
  • Domain errors (TaskNotFoundError, etc.) are never retried.

retry_predicate is configurable for custom logic, and on_retry is exposed as a hook for logging/metrics. Streaming methods (send_message_streaming, subscribe) only retry before the first event is yielded.

Describe alternatives you've considered
  • Retry via ClientCallInterceptor — not feasible; after() only fires on successful results, so interceptors never see exceptions.
  • Transport-specific retry (httpx custom transport, gRPC retryPolicy / UnaryUnaryClientInterceptor) — operates below the SDK's exception layer, requires two separate configurations, and doesn't cover all three transports uniformly.
  • Retry inside each transport implementation — triples the logic across JsonRpcTransport, RestTransport, GrpcTransport and forces every future transport to reimplement it.
Additional context

Purely additive: new RetryTransport class, tests, and one export change. No new dependencies — the grpc import is conditional, matching the SDK's existing pattern. ClientFactory integration is left as a follow-up.

Code of Conduct
  • I agree to follow this project's Code of Conduct
主要语言
Python
星标
2.2k
派生
496
平均合并
2 天 6 小时
30 天内合并 PR
19

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

a2aproject/a2a-python 的其他 Issue

查看 a2aproject/a2a-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。