Repository navigation
fix(memory): 支持默认模型热更新并透传模型服务错误 - #748
openjiuwen-sync-bot[bot] wants to merge 1 commit into
Conversation
|
|
1 similar comment
|
|
|
head_sha: 变更摘要本 PR 主要围绕内存模块的模型服务调用做两类改动:一是新增 主要改动
|
|
head_sha: 代码审查审查结论本次共报告 5 个问题:P0 0 个、P1 0 个、P2 1 个、P3 4 个。 整体风险判断:改动方向正确(模型服务错误分类化 + 保留用户显式覆盖的默认模型热更新),HTTP/SDK 两侧的错误映射与脱敏链路基本自洽,测试也覆盖了关键路径,未发现会导致构建失败、数据损坏或凭据泄漏的严重缺陷。主要风险集中在新增的 逐文件审查确认
💬 仅评论 |
| def publish(model): | ||
| result = runtime.configuration.update_defaults(defaults(model), security=object()) | ||
| assert result["applied"] | ||
| return result["version"] |
There was a problem hiding this comment.
head_sha: df505f2ea3bd080d985e5eed291284d79561baa4
🟡 Medium Priority
建议:增加一个 authorize=lambda sec, op: False(或抛权限错误)的运行时用例,断言 update_defaults 抛 PermissionDeniedError,且随后 reply() 仍返回旧模型,覆盖该特权接口的权限闸门。
| previous = self._base | ||
| candidate = apply_assembly_overrides(previous, changes, self._fields.fields) | ||
| self._validate_context(candidate) | ||
| self._inherited_instances.update(instances) |
There was a problem hiding this comment.
head_sha: df505f2ea3bd080d985e5eed291284d79561baa4
🟡 Medium Priority
变更行:update_defaults 在 try 之前就执行 self._inherited_instances.update(instances)(第 362 行),而 self._base 有回滚(第 371-373 行),_inherited_instances 没有。
影响链:_inherited_instances 是 save() 中 _pin_inherited_endpoints 的唯一开关 —— 一旦某个实例被标记为“继承宿主默认”,用户后续只要改任一 endpoint 字段(如仅改 llm_model),就会把当时的完整连接(target/base_url/api_key)钉进用户覆盖层。
失效模式:宿主调用 update_defaults 后,若第 369 行 _validate_context(self.assembly_context(snapshot)) 或第 370 行 commit 抛错(如用户存量覆盖与新默认冲突、版本冲突),_base 已回滚、宿主默认并未生效,但实例仍留在 _inherited_instances 里。此后该用户的普通保存会被静默钉住“旧的”默认连接,宿主下一次成功的默认切换对这个用户不再生效,与 S08 中「恢复整组连接后使用最新宿主默认值」的设计相反,且状态在进程内永久残留(无清理路径)。触发条件明确,但需要一次失败的热更新,故置信度中等。
建议:把 self._inherited_instances.update(instances) 移到提交成功之后(或在 except 分支中把它回滚到进入函数前的副本),保证它与 self._base 的提交/回滚语义一致:只有宿主默认真正落盘并发布后才登记“继承”状态。
df505f2 to
a2dc897
Compare
a2dc897 to
884ea14
Compare
| logger.error("OpenAILLM: invalid model service response") | ||
| raise LLMServiceError(response_error=True) from exc | ||
|
|
||
| content = response.choices[0].message.content |
There was a problem hiding this comment.
head_sha: 884ea14dabf37249c57de3793986d901fccd8772
response.choices[0] 在 try 块之外。上游对 200 返回空 choices(内容过滤、部分兼容网关会这么回)时这里抛 IndexError,不会经过上面 APIError → LLMServiceError(response_error=True) 的转换:call_llm_with_retry 把它当普通异常重试,重试耗尽后在 HTTP 入口变成 500 InternalError,和本 PR 写的「响应异常映射 502、不重试」的契约不一致。建议取 content 前判断 if not response.choices: raise LLMServiceError(response_error=True),或把这一行也挪进 try。
Paired: GitHub #748 ↔ GitCode !531
What type of PR is this?
/kind
Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues: