diff --git a/metagpt/actions/action_node.py b/metagpt/actions/action_node.py index 4f61af4ed..ca41c76a5 100644 --- a/metagpt/actions/action_node.py +++ b/metagpt/actions/action_node.py @@ -469,8 +469,10 @@ class ActionNode: return dict() prompt = template.format( - nodes_output=json.dumps(nodes_output, ensure_ascii=False), tag=TAG, constraint=FORMAT_CONSTRAINT, - prompt_schema="json" + nodes_output=json.dumps(nodes_output, ensure_ascii=False), + tag=TAG, + constraint=FORMAT_CONSTRAINT, + prompt_schema="json", ) content = await self.llm.aask(prompt) @@ -568,7 +570,7 @@ class ActionNode: example=example, instruction=instruction, constraint=FORMAT_CONSTRAINT, - prompt_schema="json" + prompt_schema="json", ) # step2, use `_aask_v1` to get revise structure result diff --git a/metagpt/schema.py b/metagpt/schema.py index 0a7a07b03..22bb359b6 100644 --- a/metagpt/schema.py +++ b/metagpt/schema.py @@ -232,7 +232,7 @@ class Message(BaseModel): return any_to_str_set(send_to if send_to else {MESSAGE_ROUTE_TO_ALL}) @field_serializer("instruct_content", mode="plain") - def ser_instruct_content(self, ic: BaseModel) -> Union[str, None]: + def ser_instruct_content(self, ic: BaseModel) -> Union[dict, None]: ic_dict = None if ic: # compatible with custom-defined ActionOutput diff --git a/tests/metagpt/serialize_deserialize/test_write_prd.py b/tests/metagpt/serialize_deserialize/test_write_prd.py index 820ee237c..afc483e9a 100644 --- a/tests/metagpt/serialize_deserialize/test_write_prd.py +++ b/tests/metagpt/serialize_deserialize/test_write_prd.py @@ -18,5 +18,5 @@ async def test_action_serdeser(new_filename): new_action = WritePRD(**ser_action_dict) assert new_action.name == "WritePRD" - action_output = await new_action.run(with_messages=Message(content="write a cli snake game")) - assert len(action_output.content) > 0 + with pytest.raises(FileNotFoundError): + await new_action.run(with_messages=Message(content="write a cli snake game"))