d4e7e2672c06525b6c09c614eaf507a799476d54
复核时发现原修复建议("改走 ModelGenerationService,或用 self.generate_with_model") **前提不成立**: - OpenAICompatibleGateway.generate(endpoint_code, prompt, timeout_ms) -> str (model_gateway.py:57)与 ModelDispatchService.generate(endpoints, prompt) -> ModelExecution (:248)都是"给一段 prompt、拿一段文本";ModelExecution 的字段只有 (endpoint_code, text, attempts, degraded)(:226-231)。 - 而风控需要的是 **messages 数组 + tools(function calling)+ 解析 tool_calls**, 基座完全没有这种形态的入口。 所以这不是"绕过",是基座缺能力时的补位,而且补得规矩:端点选择直接用基座的 DatabaseModelEndpointResolver;降级策略与 ModelDispatchService.generate 一致 (顺序尝试 + max_attempts 默认 2);错误映射也复用基座同一套 UpstreamTimeoutError / DependencyUnavailableError。 仍成立的两点:① bootstrap.py:262-265 的 lambda 让 model_client 注入点形同虚设, 无论走哪条路都该改;② HTTP 调用逻辑与 gateway 重复了一份,gateway 将来的限流/成本统计 风控享受不到。 **正确的修法比原建议大**:给基座**新增** chat(messages, tools) 形态的入口 (ModelGateway → OpenAICompatibleGateway → ModelDispatchService → ModelGenerationService → BaseAgent),再让风控改用。因为只是新增方法、不改现有行为,对已有 Agent 零影响; 但涉及基座核心链路,是否做需要项目方定,**本轮未实施**。
Description
番茄炒蛋组
18 MiB
Languages
Python
99.9%