#2799·smolagents

BUG: Model.to_dict() 删除自定义角色转换和客户端参数设置 (api_base/organization/project/azure_endpoint),因此保存的代理会重新加载到错误的端点和角色映射

作者: BlueX888创建于 2026年9月15日更新于 2026年9月16日

Problem

Model.to_dict() (src/smolagents/models.py:596) does not export custom_role_conversions, and it does not export the connection settings (api_base, organization, project, azure_endpoint) for the models that hold them inside self.client_kwargs. MultiStepAgent.to_dict() embeds this dict under "model" (src/smolagents/agents.py:997) and save() writes it to agent.json (src/smolagents/agents.py:940), while MultiStepAgent.from_dict() rebuilds the model from it via model_class.from_dict(model_info["data"]) (src/smolagents/agents.py:1029). A saved agent therefore reloads with default role conversions and no custom endpoint, silently pointing back at api.OpenAI.com (or the provider default) instead of the user's endpoint.

内容来源: huggingface/smolagents