![[Bug]: Router retry_policy set via UI/ POST / Config/update is silently dropped (never persisted or applied)](https://www.chat-gpts.plus/wp-content/uploads/2026/07/31308-001b0085.jpg)
[Bug]: Router retry_policy set via UI/ POST / Config/update is silently dropped (never persisted or applied)
快速结论:该问题发生在通过 LiteLLM Admin UI 或直接调用 POST /config/update 接口设置 Router 级别 retry_policy 时,配置项被静默丢弃,既不生效也不报错。优先检查后端版本是否已包含修复补丁,或者确认 _allowed_settings 白名单中是否包含 retry_policy。
问题场景
用户运行 LiteLLM Proxy Server 时,通过 Admin UI 的 Router Settings 页面(Reliability & Retries 区域)设置 retry_policy(例如:{"RateLimitErrorRetries": 3}),点击保存后 UI 提示成功,但实际调用 GET /get/config/callbacks 检查时发现配置未被持久化,且重试行为未按预期生效。同样问题也影响 “Allowed Fails”、“Cooldown Time”、“Timeout” 等 “Reliability & Retries” 区域的其它设置。
报错原文
# 后端返回 422 错误(仅影响少数路径,前端未捕获):
{"detail":[{"type":"list_type","loc":["body","router_settings","routing_groups"],"msg":"Input should be a valid list","input":"[]"}]}
# 更常见的表现是:无报错,但配置被静默丢弃,retry_policy 字段完全消失
原因分析
根本原因在于 LiteLLM 后端存在两处代码缺口,导致 retry_policy 字段在请求处理链中被两次丢弃:
- 数据模型缺失:
litellm/types/router.py中的UpdateRouterConfig数据类未定义retry_policy字段,导致该字段在反序列化时被静默忽略,从未传递到业务逻辑层。 - 白名单过滤:
litellm/router.py中Router.update_settings()方法维护了一个_allowed_settings白名单列表,该列表包含了model_group_retry_policy但遗漏了retry_policy。白名单之外的键会进入一个只输出 debug 日志的分支,属性值永远不会被设置到 Router 实例上。
此外,前端在遇到后端返回的 422 错误时也未展示错误提示,导致用户误以为保存成功。
环境排查
- LiteLLM 版本:v1.87.0(首次报告),v1.90.1(仍有部分 UI 字段受影响,如 Allowed Fails、Cooldown Time、Timeout)
- 检查
litellm/router.py中Router.update_settings()的_allowed_settings列表是否包含retry_policy字符串 - 检查
litellm/types/router.py中UpdateRouterConfig类是否声明了retry_policy: Optional[dict] = None
解决步骤
- 升级 LiteLLM 版本:该问题已在修复分支
adhavan18:issue-31308-retry-policy-update上解决,并合入主分支。请升级到包含此修复的版本(至少 v1.91.0 及以上,具体以 release notes 为准)。 - 检查修复内容:如果无法升级,可手动验证以下两个文件是否已修改:
litellm/types/router.py:在UpdateRouterConfig中增加retry_policy: Optional[dict] = Nonelitellm/router.py:在Router.update_settings()方法的_allowed_settings列表中加入"retry_policy",并添加dict → RetryPolicy类型转换逻辑(与Router.__init__中的处理方式一致)
- 直接调用 API 测试(可优先尝试):升级后,使用以下 curl 请求验证配置是否被正确接受:
curl -X POST http://localhost:4000/config/update \ -H "Content-Type: application/json" \ -d '{"router_settings": {"retry_policy": {"RateLimitErrorRetries": 3}}}' - 检查 UI 字段:如果使用的是新版本但 UI 中 “Reliability & Retries” 区域的其它字段仍无效,请确认后端是否返回了 422 错误(可查看 Proxy Server 的日志或浏览器开发者工具 Network 面板)。
- 自定义补丁:对于临时无法升级的场景,可参考修复分支 issue-31308-retry-policy-update 手动合并代码修改。
验证方法
应用修复后,执行以下步骤确认问题已解决:
- 调用
POST /config/update设置一个测试用的retry_policy,例如{"RateLimitErrorRetries": 3} - 调用
GET /get/config/callbacks检查返回的router_settings中是否包含了刚刚设置的retry_policy - 模拟一个 RateLimitError 请求,确认重试次数是否符合配置(例如发起请求后观察日志中的重试行为)
- 对于 UI 中的其他字段(Allowed Fails、Cooldown Time 等),同样检查 API 返回是否包含正确的配置值,且无 422 错误



