Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 断点恢复会重置 Role 的 rc.watch 属性 #1248

Open
fachebot opened this issue May 7, 2024 · 1 comment
Open

[Bug] 断点恢复会重置 Role 的 rc.watch 属性 #1248

fachebot opened this issue May 7, 2024 · 1 comment
Assignees

Comments

@fachebot
Copy link

fachebot commented May 7, 2024

Bug description
我正在测试端点恢复功能,首先调用 Team 对象的 serialize 方法将 Team 对象序列化为json格式并保存到 team.json 文件,然后调用Tam类的deserialize方法从json文件恢复Team对象。这时候问题出现了,我观察到 Role 的 validate_role_extra 方法将会被调用两次,正常情况下它应该只调用一次。

调用顺序如下(Researcher继承Role):

  1. Role.validate_role_extra
  2. Researcher.init
  3. Role.validate_role_extra

由于多调用了一次 validate_role_extra 方法,Role 的 rc.watch 属性会被重置为 UserRequirement,导致无法从中断前的 Message 开始重新执行。相关代码如下:

    @model_validator(mode="after")
    def validate_role_extra(self):
        self._process_role_extra()
        return self

    def _process_role_extra(self):
        kwargs = self.model_extra or {}

        if self.is_human:
            self.llm = HumanProvider(None)

        self._check_actions()
        self.llm.system_prompt = self._get_prefix()
        self.llm.cost_manager = self.context.cost_manager
        self._watch(kwargs.pop("watch", [UserRequirement]))

        if self.latest_observed_msg:
            self.recovered = True

这个错误似乎跟 Role 继承 SerializationMixin 有关。

@fachebot fachebot changed the title 断点恢复会重置 Role 的 rc.watch 属性 [Bug] 断点恢复会重置 Role 的 rc.watch 属性 May 7, 2024
@geekan
Copy link
Owner

geekan commented May 18, 2024

@better629 Can you take a look at this question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants