diff --git a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py index 43d88c5ad..6d43a78ec 100644 --- a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +++ b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py @@ -414,10 +414,11 @@ async def _save_to_history( # using agent context messages to save to history message_to_save = [] + skipped_initial_system = False for message in all_messages: - if message.role == "system": - # we do not save system messages to history - continue + if message.role == "system" and not skipped_initial_system: + continue # skip all system messages until the first non-system message + skipped_initial_system = True if message.role in ["assistant", "user"] and getattr( message, "_no_save", None ):