Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Commit 0dcbe6e

Browse files
committed
Ensure system messages are always added
1 parent 0c2ddc0 commit 0dcbe6e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/controlflow/events/message_compiler.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ def convert_system_messages(
113113
messages: list[BaseMessage], rules: LLMRules
114114
) -> list[BaseMessage]:
115115
"""
116-
Converts system messages to human messages if the LLM doesnt support system messages, either at all or in the first position.
116+
Converts system messages to human messages if the LLM doesnt support system
117+
messages, either at all or in the first position.
117118
"""
118-
119119
new_messages = []
120120
for i, message in enumerate(messages):
121121
if isinstance(message, SystemMessage):
122-
# if system messages are not supported OR if they must be first and this is not the first message
123-
# THEN convert the message to a human message
122+
# If system messages are not supported OR if they must be first and
123+
# this is not the first message, THEN convert the message to a human message
124124
if not rules.allow_system_messages or (
125125
i > 0 and rules.require_system_message_first
126126
):
@@ -129,6 +129,9 @@ def convert_system_messages(
129129
content=f"ORCHESTRATOR: {message.content}", name=message.name
130130
)
131131
)
132+
else:
133+
# If the system message is allowed, add it as-is
134+
new_messages.append(message)
132135
else:
133136
new_messages.append(message)
134137
return new_messages

0 commit comments

Comments
 (0)