Skip to content

refactor(models): 统一模型错误分类与重试边界 - #6047

Merged
qin-ctx merged 20 commits into
mainfrom
fix/model-error-classification
Oct 15, 2026
Merged

qin-ctx merged 20 commits into
mainfrom
fix/model-error-classification

Conversation

@hezhang-1216

Copy link
Copy Markdown
Collaborator

Description

统一 VLM 与 Embedding Provider 的错误分类和重试边界,使用结构化 ModelError 替代基于错误消息关键词的重试判断。

每层仅处理自身负责的错误;未处理或恢复失败的错误保持原异常语义向上透传。

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

无。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • 新增统一的 ModelErrorKind 和 ModelError,记录 Provider、HTTP 状态码及结构化业务码。
  • 在 OpenAI、Ark、LiteLLM、Gemini 等 Provider 边界统一转换官方 SDK/API 异常,并保留原始异常链。
  • 统一 Retry 层仅重试瞬态服务错误、网络错误、限流错误和未知 API 错误;其余错误原样向上透传。
  • 关闭 Provider SDK 内置重试,避免与统一 Retry 层产生重试叠加。
  • 保留旧错误分类接口作为兼容桥,不修改 Credential Failover、Model Failover、Queue 和业务层策略。
  • 补充错误映射、异常透传、重试预算及 Provider 边界回归测试。

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

本地专项回归:337 passed, 1 skipped。

同时通过:

  • ruff check
  • git diff --check

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用。

Additional Notes

本分支已合并最新 main。冲突解决时保留了主线统一重试包装器,并在其上接入结构化模型错误分类。

zhanghe.1216 added 8 commits October 12, 2026 20:07
撤回全局错误分类和无关 API 扩张,使本次改造仅聚焦 VLM 重试职责收拢。
将重试决策集中到 RetryEmbedder,避免 Provider 与 SDK 重试叠乘,同时保持组合模型和账号资源语义。
保留主线统一重试包装器,并接入结构化模型错误分类边界。

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一 Provider 错误边界的方向合理,但当前分类会影响已有的备用模型切换和账户熔断语义。已用真实 OpenAI SDK 配合模拟 HTTP 响应,对比 base 与当前提交,确认两项回归:主模型返回 model_not_found 时不再尝试健康的备用模型;输入过长的 HTTP 500 响应被作为服务故障重试并累计到账户熔断。两项具体问题已分别标在代码行上,需要在合并前解决。

Comment thread openviking/utils/model_retry.py Outdated
Comment thread openviking/models/model_error.py
zhanghe.1216 added 2 commits October 14, 2026 20:25
直接基于 ModelErrorKind 驱动重试、凭证切换与熔断策略,确保模型不存在时切换备用配置,并优先解析 Provider 结构化业务错误。
保留主线中的快速损坏 ZIP 错误断言,并删除慢速套件中的重复用例。
@hezhang-1216
hezhang-1216 requested a review from qin-ctx October 15, 2026 01:56
@ZaynJarvis ZaynJarvis added the kernel Core server, runtime, storage, retrieval, SDK, and CLI. label Oct 15, 2026

@qin-ctx qin-ctx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复核提交 0fde1b5,仍有两项需要在合并前解决:原先已处理的批处理容量错误会触发无效重试,并在连续失败后拦住同一账户的正常查询;VikingBot 汇总收到“内容太长”后不再执行压缩,原来能完成的任务变成失败。

第一项已在原讨论补充复核结果和兼容范围,第二项见本次行内评论。上次提出的备用模型切换问题已经修复。

Comment thread bot/vikingbot/compile/ops/reduce.py
@qin-ctx
qin-ctx merged commit acd7caf into main Oct 15, 2026
8 of 9 checks passed
@qin-ctx
qin-ctx deleted the fix/model-error-classification branch October 15, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Core server, runtime, storage, retrieval, SDK, and CLI.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants