Save the contract for an agent
(self, agent_names: Optional[List[str]] = None)
| 1032 | return restored_config |
| 1033 | |
| 1034 | async def save_contract(self, agent_names: Optional[List[str]] = None): |
| 1035 | """Save the contract for an agent""" |
| 1036 | contract = [] |
| 1037 | if agent_names is not None: |
| 1038 | for index, agent_name in enumerate(agent_names): |
| 1039 | agent_info = await self.get_info(agent_name) |
| 1040 | text = agent_info.text |
| 1041 | contract.append(f"{index + 1:04d}\n{text}\n") |
| 1042 | else: |
| 1043 | for index, agent_name in enumerate(self._agent_configs.keys()): |
| 1044 | agent_info = await self.get_info(agent_name) |
| 1045 | text = agent_info.text |
| 1046 | contract.append(f"{index + 1:04d}\n{text}\n") |
| 1047 | contract_text = "---\n".join(contract) |
| 1048 | with open(self.contract_path, "w", encoding="utf-8") as f: |
| 1049 | f.write(contract_text) |
| 1050 | logger.info(f"| 📝 Saved {len(contract)} agents contract to {self.contract_path}") |
| 1051 | |
| 1052 | async def load_contract(self) -> str: |
| 1053 | """Load the contract for an agent""" |