diff --git a/src/chat/utils/prompt_builder.py b/src/chat/utils/prompt_builder.py index ab8ab3d9..ca94d542 100644 --- a/src/chat/utils/prompt_builder.py +++ b/src/chat/utils/prompt_builder.py @@ -25,6 +25,11 @@ def get_tool_history_prompt(message_id: Optional[str] = None) -> str: Returns: 格式化的工具历史提示词 """ + from src.config.config import global_config + + if not global_config.tool.history.enable_prompt_history: + return "" + return tool_history_manager.get_recent_history_prompt( chat_id=message_id ) diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 37adc2e4..4239efcb 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -289,6 +289,9 @@ class ToolHistoryConfig(ConfigBase): enable_history: bool = True """是否启用工具历史记录""" + + enable_prompt_history: bool = True + """是否在提示词中加入工具历史记录""" max_history: int = 100 """历史记录最大保存数量""" diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index d43ece1c..db713ec5 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -116,6 +116,7 @@ enable_tool = false # 是否在普通聊天中启用工具 [tool.history] enable_history = true # 是否启用工具调用历史记录 +enable_prompt_history = true # 是否在提示词中加入工具历史记录 max_history = 5 # 每个会话最多保留的历史记录数 [mood]