Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

合并teamleader 和sweagent的原系统提示词

黄伟韬d788722bc2e9
diff --git a/metagpt/prompts/di/role_zero.py b/metagpt/prompts/di/role_zero.py
index a92a3c075..9742cab4a 100644
--- a/metagpt/prompts/di/role_zero.py
+++ b/metagpt/prompts/di/role_zero.py
@@ -48,6 +48,8 @@ Special Command: Use {{"command_name": "end"}} to do nothing or indicate complet
"""
CMD_PROMPT = """
+{current_state}
+
# Current Plan
{plan_status}
diff --git a/metagpt/prompts/di/swe_agent.py b/metagpt/prompts/di/swe_agent.py
index 87332f9ef..a737d4a72 100644
--- a/metagpt/prompts/di/swe_agent.py
+++ b/metagpt/prompts/di/swe_agent.py
@@ -233,10 +233,12 @@ These examples are provided to demonstrate the output style that expected to be
# IMPORTANT TIPS
{IMPORTANT_TIPS}
+
+Avoid repeating the same command. Instead, please think about the current situation and provide the next bash command to execute in JSON format:"
+"""
+CURRENT_BASH_STATE = """
# Output Next Step
The current bash state is:
(Open file: {{open_file}})
(Current directory: {{working_dir}})
-
-Avoid repeating the same command. Instead, please think about the current situation and provide the next bash command to execute in JSON format:"
"""
diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.py
index af15fb745..75d070822 100644
--- a/metagpt/roles/di/role_zero.py
+++ b/metagpt/roles/di/role_zero.py
@@ -49,6 +49,7 @@ class RoleZero(Role):
goal: str = ""
system_prompt: str = SYSTEM_PROMPT # Use None to conform to the default value at llm.aask
cmd_prompt: str = CMD_PROMPT
+ cmd_prompt_current_state: str = ""
thought_guidance: str = THOUGHT_GUIDANCE
instruction: str = ROLE_INSTRUCTION
task_type_desc: str = None
@@ -161,6 +162,7 @@ class RoleZero(Role):
### Make Decision Dynamically ###
prompt = self.cmd_prompt.format(
+ current_state=self.cmd_prompt_current_state,
plan_status=plan_status,
current_task=current_task,
requirements_constraints=self.requirements_constraints,
diff --git a/metagpt/roles/di/swe_agent.py b/metagpt/roles/di/swe_agent.py
index c8081066e..13fc87c60 100644
--- a/metagpt/roles/di/swe_agent.py
+++ b/metagpt/roles/di/swe_agent.py
@@ -3,7 +3,11 @@ import json
from pydantic import Field
from metagpt.logs import logger
-from metagpt.prompts.di.swe_agent import MINIMAL_EXAMPLE, NEXT_STEP_TEMPLATE
+from metagpt.prompts.di.swe_agent import (
+ CURRENT_BASH_STATE,
+ MINIMAL_EXAMPLE,
+ NEXT_STEP_TEMPLATE,
+)
from metagpt.roles.di.role_zero import RoleZero
from metagpt.tools.libs.git import git_create_pull
from metagpt.tools.libs.terminal import Bash
@@ -49,7 +53,7 @@ class SWEAgent(RoleZero):
"""
state_output = await self.terminal.run("state")
bash_state = json.loads(state_output)
- self.instruction = self._instruction.format(**bash_state).strip()
+ self.cmd_prompt_current_state = CURRENT_BASH_STATE.formate(**bash_state).strip()
async def _parse_commands_for_eval(self):
"""