Fix Extra planning (#362)

* fix Extra planning
This commit is contained in:
BUI Van Tuan 2025-01-28 09:21:58 +01:00 committed by GitHub
parent 68f3da12ea
commit 3b5c99e87a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 13 deletions

View File

@ -265,14 +265,14 @@ class MultiStepAgent:
elif isinstance(step_log, PlanningStep): elif isinstance(step_log, PlanningStep):
thought_message = { thought_message = {
"role": MessageRole.ASSISTANT, "role": MessageRole.ASSISTANT,
"content": "[FACTS LIST]:\n" + step_log.facts.strip(), "content": [{"type": "text", "text": "[FACTS LIST]:\n" + step_log.facts.strip()}],
} }
memory.append(thought_message) memory.append(thought_message)
if not summary_mode: if not summary_mode:
thought_message = { thought_message = {
"role": MessageRole.ASSISTANT, "role": MessageRole.ASSISTANT,
"content": "[PLAN]:\n" + step_log.plan.strip(), "content": [{"type": "text", "text": "[PLAN]:\n" + step_log.plan.strip()}],
} }
memory.append(thought_message) memory.append(thought_message)
@ -700,28 +700,33 @@ Now begin!""",
# Redact updated facts # Redact updated facts
facts_update_system_prompt = { facts_update_system_prompt = {
"role": MessageRole.SYSTEM, "role": MessageRole.SYSTEM,
"content": SYSTEM_PROMPT_FACTS_UPDATE, "content": [{"type": "text", "text": SYSTEM_PROMPT_FACTS_UPDATE}],
} }
facts_update_message = { facts_update_message = {
"role": MessageRole.USER, "role": MessageRole.USER,
"content": USER_PROMPT_FACTS_UPDATE, "content": [{"type": "text", "text": USER_PROMPT_FACTS_UPDATE}],
} }
facts_update = self.model([facts_update_system_prompt] + agent_memory + [facts_update_message]).content facts_update = self.model([facts_update_system_prompt] + agent_memory + [facts_update_message]).content
# Redact updated plan # Redact updated plan
plan_update_message = { plan_update_message = {
"role": MessageRole.SYSTEM, "role": MessageRole.SYSTEM,
"content": SYSTEM_PROMPT_PLAN_UPDATE.format(task=task), "content": [{"type": "text", "text": SYSTEM_PROMPT_PLAN_UPDATE.format(task=task)}],
} }
plan_update_message_user = { plan_update_message_user = {
"role": MessageRole.USER, "role": MessageRole.USER,
"content": USER_PROMPT_PLAN_UPDATE.format( "content": [
task=task, {
tool_descriptions=get_tool_descriptions(self.tools, self.tool_description_template), "type": "text",
managed_agents_descriptions=(show_agents_descriptions(self.managed_agents)), "text": USER_PROMPT_PLAN_UPDATE.format(
facts_update=facts_update, task=task,
remaining_steps=(self.max_steps - step), tool_descriptions=get_tool_descriptions(self.tools, self.tool_description_template),
), managed_agents_descriptions=(show_agents_descriptions(self.managed_agents)),
facts_update=facts_update,
remaining_steps=(self.max_steps - step),
),
}
],
} }
plan_update = self.model( plan_update = self.model(
[plan_update_message] + agent_memory + [plan_update_message_user], [plan_update_message] + agent_memory + [plan_update_message_user],

View File

@ -433,7 +433,7 @@ Now begin! Write your plan below."""
SYSTEM_PROMPT_FACTS_UPDATE = """ SYSTEM_PROMPT_FACTS_UPDATE = """
You are a world expert at gathering known and unknown facts based on a conversation. You are a world expert at gathering known and unknown facts based on a conversation.
Below you will find a task, and ahistory of attempts made to solve the task. You will have to produce a list of these: Below you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:
### 1. Facts given in the task ### 1. Facts given in the task
### 2. Facts that we have learned ### 2. Facts that we have learned
### 3. Facts still to look up ### 3. Facts still to look up