feat: skip saving head system messages in history (#4538)
* feat: skip saving the first system message in history * fix: rename variable for clarity in system message handling * fix: update logic to skip all system messages until the first non-system message
This commit is contained in:
@@ -414,10 +414,11 @@ class InternalAgentSubStage(Stage):
|
||||
|
||||
# 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
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user