MCPcopy
hub / github.com/huggingface/smolagents / write_memory_to_messages

Method write_memory_to_messages

src/smolagents/agents.py:758–770  ·  view source on GitHub ↗

Reads past llm_outputs, actions, and observations or errors from the memory into a series of messages that can be used as input to the LLM. Adds a number of keywords (such as PLAN, error, etc) to help the LLM.

(
        self,
        summary_mode: bool = False,
    )

Source from the content-addressed store, hash-verified

756 self.interrupt_switch = True
757
758 def write_memory_to_messages(
759 self,
760 summary_mode: bool = False,
761 ) -> list[ChatMessage]:
762 """
763 Reads past llm_outputs, actions, and observations or errors from the memory into a series of messages
764 that can be used as input to the LLM. Adds a number of keywords (such as PLAN, error, etc) to help
765 the LLM.
766 """
767 messages = self.memory.system_prompt.to_messages(summary_mode=summary_mode)
768 for memory_step in self.memory.steps:
769 messages.extend(memory_step.to_messages(summary_mode=summary_mode))
770 return messages
771
772 def _step_stream(
773 self, memory_step: ActionStep

Callers 8

provide_final_answerMethod · 0.95
__call__Method · 0.95
_step_streamMethod · 0.80
_step_streamMethod · 0.80
answer_single_questionFunction · 0.80
answer_single_questionFunction · 0.80

Calls 1

to_messagesMethod · 0.45

Tested by 1