@@ -464,12 +464,14 @@ def planning_step(self, task, is_first_step: bool, step: int) -> None:
464464 "content" : [
465465 {
466466 "type" : "text" ,
467- "text" : f"""Here is the task:
468- ```
469- { task }
470- ```
471- Now begin!""" ,
472- }
467+ "text" : textwrap .dedent (
468+ f"""Here is the task:
469+ ```
470+ { task }
471+ ```
472+ Now begin!"""
473+ ),
474+ },
473475 ],
474476 }
475477 input_messages = [message_prompt_facts , message_prompt_task ]
@@ -500,14 +502,18 @@ def planning_step(self, task, is_first_step: bool, step: int) -> None:
500502 )
501503 answer_plan = chat_message_plan .content
502504
503- final_plan_redaction = f"""Here is the plan of action that I will follow to solve the task:
504- ```
505- { answer_plan }
506- ```"""
507- final_facts_redaction = f"""Here are the facts that I know so far:
508- ```
509- { answer_facts }
510- ```""" .strip ()
505+ final_plan_redaction = textwrap .dedent (
506+ f"""Here is the plan of action that I will follow to solve the task:
507+ ```
508+ { answer_plan }
509+ ```"""
510+ )
511+ final_facts_redaction = textwrap .dedent (
512+ f"""Here are the facts that I know so far:
513+ ```
514+ { answer_facts }
515+ ```""" .strip ()
516+ )
511517 self .memory .steps .append (
512518 PlanningStep (
513519 model_input_messages = input_messages ,
@@ -533,7 +539,7 @@ def planning_step(self, task, is_first_step: bool, step: int) -> None:
533539 "content" : [{"type" : "text" , "text" : self .prompt_templates ["planning" ]["update_facts_pre_messages" ]}],
534540 }
535541 facts_update_post_messages = {
536- "role" : MessageRole .SYSTEM ,
542+ "role" : MessageRole .USER ,
537543 "content" : [{"type" : "text" , "text" : self .prompt_templates ["planning" ]["update_facts_post_messages" ]}],
538544 }
539545 input_messages = [facts_update_pre_messages ] + memory_messages + [facts_update_post_messages ]
@@ -553,12 +559,12 @@ def planning_step(self, task, is_first_step: bool, step: int) -> None:
553559 ],
554560 }
555561 update_plan_post_messages = {
556- "role" : MessageRole .SYSTEM ,
562+ "role" : MessageRole .USER ,
557563 "content" : [
558564 {
559565 "type" : "text" ,
560566 "text" : populate_template (
561- self .prompt_templates ["planning" ]["update_plan_pre_messages " ],
567+ self .prompt_templates ["planning" ]["update_plan_post_messages " ],
562568 variables = {
563569 "task" : task ,
564570 "tools" : self .tools ,
0 commit comments