已合并
fix(deployment): 显式 id=None 时自动生成,避免部署状态互相覆盖与 fallback 失效 #343
庄昭雄创建于 10月18日
fix(deployment): 显式 id=None 时自动生成,避免部署状态互相覆盖与 fallback 失效 #343
已合并
Pull Request已成功合入, 合并人@openJiuwen-bot
(感谢 庄昭雄 的贡献)atomgit-bot
10月18日 评论:
10月18日 评论:
变更摘要
本 PR 修复 intelli_router 中 Deployment.id 缺省语义失效的问题:由于 dataclass 的 default_factory 仅在省略参数时生效,而 agent-core 包装层会把配置中缺失的 id 原样透传为 id=None,导致多个部署共用同一 id(被折叠为 "null"),进而使 ReliableRouter 的 deployment_status / consecutive_failures / cooldown_until 按 key 互相覆盖,并使失败剔除逻辑一次清空全部 None-id 候选、fallback 失效。修复在 Deployment.__post_init__ 中补全显式 None 的自动生成路径,并新增校验与测试。
主要改动
- 补全显式
id=None的缺省语义: 在intelli_router/core/deployment.py的Deployment.__post_init__中,当self.id is None时自动生成 8 位 id(str(uuid.uuid4())[:8]),与default_factory行为保持一致,避免多部署共享id=None导致状态互相覆盖与 fallback 失效。 - 新增
id类型与空白校验: 非字符串id抛TypeError,空白字符串抛ValueError,使非法输入被显式拒绝而非静默透传。 - 新增
id相关测试: 在intelli_router/tests/test_core_deployment.py中新增 8 条用例,覆盖显式id=None自动生成、两次生成不同、非字符串TypeError与空白ValueError。 - 接口行为变更:
Deployment(id=None)从「保持 None」变为「自动生成 id」,属于文档既有语义的补齐,调用方无需改动。


不准确?
10月18日 将YiyangShao,xinyu-jiuwen设为审查人
atomgit-bot
10月18日 评论:
10月18日 评论:
atomgit-bot
10月18日 评论:
10月18日 评论:
10月18日 添加了label:sig/sig-agent-protocol
此处折叠了45条消息 查看更多
openJiuwen-bot
17 天前 评论:
17 天前 评论:
17 天前 解决了最后一个问题
17 天前 关闭了关联的issue
17 天前 合入了pull request
17 天前 删除了label:ci-successful
Paired: GitHub #139 ↔ GitCode !343
What type of PR is this?
/kind bug
What does this PR do / why do we need it:
intelli_router的Deployment.id文档语义是「可选,缺省时自动生成」,但 dataclass 的default_factory只在省略参数时生效。agent-core 的包装层会把配置里的缺省值原样透传成id=None("id": dep_cfg.get("route_id") or dep_cfg.get("id")),而Deployment.__post_init__既不补全也不校验id,于是多个部署共享id=None:ReliableRouter的状态(deployment_status/consecutive_failures/cooldown_until)以d.id为 key → 全部折叠到"null",互相覆盖;available = [d for d in available if d.id != selected.id]中None != None为假 → 一次清空所有 None-id 候选,健康备用部署一次都不会被请求,直接AllDeploymentsFailed。修法(
intelli_router/core/deployment.py,+14 行):__post_init__里id is None时自动生成 8 位 id(与default_factory一致);非字符串抛TypeError、空白字符串抛ValueError。另加 8 条测试。Which issue(s) this PR fixes:
无既有 issue:已核对全仓 76 条 issue 与最近 100 条 MR,
intelli_router相关(#72/#71/#66/#51/#50/#49/…/#39、!315/!314/!303/!301/!309)全部 closed,且 #51 只校验tpm/rpm/consecutive_failures未含id;GitHub 上游route_id0 命中,历史 intelliRouter 改造 PR(#81/#84/#95/#97/#99)都 merged,缺陷在其之后仍存在。What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.):
两个本地 OpenAI 兼容 mock(A 固定 500,B 正常),
strategy="ordered-failover"、num_retries=2,不需要真实 LLM:with_ids=True,同一份代码其他不变):基线/本 PR 都INVOKE OK | bad hits 1, ok hits 1。cd intelli_router && PYTHONPATH=. pytest tests -q→ 620 passed, 3 skipped(基线 612 + 新增 8)。deployment.py、保留新测试 →8 failed, 24 passed;恢复补丁 → 32 passed。Self-checklist:(Please check carefully,and mark an x in the [] brackets. We will review your completion status.)
注意:本 PR 的 base 是
feature/intelliRouter(intelli_router子包只存在于该分支,develop上没有)。Linked Closing Issues:
Fixes #85