From faaf8b96084fd61288c53011456743ab3794fcad Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 20 Oct 2023 18:38:52 +0300 Subject: [PATCH] fix: adjust the tools after loading them from the store After retrieving the tools from the store, we must make adjustments in case any of them have been removed or if there are new tools available. --- .../decision_maker_abci/behaviours/tool_selection.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py index 19aef2dec..1b75a05ed 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/tool_selection.py @@ -176,10 +176,8 @@ def _get_tools( ): yield from self.wait_for_condition_with_sleep(step) - def _adjust_policy_tools(self) -> None: + def _adjust_policy_tools(self, local: List[str]) -> None: """Add or remove tools from the policy to match the remote tools.""" - local = self.synchronized_data.available_mech_tools - # remove tools if they are not available anymore # process the indices in reverse order to avoid index shifting when removing the unavailable tools later reversed_idx = range(len(local) - 1, -1, -1) @@ -196,11 +194,12 @@ def _set_policy(self) -> None: """Set the E Greedy Policy.""" if self.is_first_period: self._policy = self._get_init_policy() - recovered_tools = self._try_recover_mech_tools() - self.mech_tools = list(set(self.mech_tools + recovered_tools)) + local_tools = self._try_recover_mech_tools() else: self._policy = self.synchronized_data.policy - self._adjust_policy_tools() + local_tools = self.synchronized_data.available_mech_tools + + self._adjust_policy_tools(local_tools) def _get_init_policy(self) -> EGreedyPolicy: """Get the initial policy"""