mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-12 23:12:23 -06:00
Use system role instead of developer for broader model compatibility
The developer message role is not supported by all chat templates (e.g. Qwen). Switch to the standard system role which is universally supported by OpenAI-compatible APIs.
This commit is contained in:
@@ -76,15 +76,15 @@ class TestChatSessionConstruction:
|
||||
def test_system_messages_created(self, tmp_db):
|
||||
session = _make_session()
|
||||
assert len(session.system_messages) >= 1
|
||||
# At least one developer message
|
||||
# At least one system message
|
||||
roles = [m["role"] for m in session.system_messages]
|
||||
assert "developer" in roles
|
||||
assert "system" in roles
|
||||
|
||||
def test_instructions_appended_to_developer_message(self, tmp_db):
|
||||
def test_instructions_appended_to_system_message(self, tmp_db):
|
||||
session = _make_session(instructions="Always be concise.")
|
||||
dev_msgs = [m for m in session.system_messages if m["role"] == "developer"]
|
||||
assert len(dev_msgs) >= 1
|
||||
assert "Always be concise." in dev_msgs[0]["content"]
|
||||
sys_msgs = [m for m in session.system_messages if m["role"] == "system"]
|
||||
assert len(sys_msgs) >= 1
|
||||
assert "Always be concise." in sys_msgs[0]["content"]
|
||||
|
||||
def test_full_messages_returns_system_plus_conversation(self, tmp_db):
|
||||
session = _make_session()
|
||||
|
||||
@@ -221,7 +221,7 @@ class ChatSession:
|
||||
model=self.model,
|
||||
messages=[
|
||||
{
|
||||
"role": "developer",
|
||||
"role": "system",
|
||||
"content": (
|
||||
"# Instructions\n\n"
|
||||
"You are a conversation title generator. "
|
||||
@@ -354,7 +354,7 @@ class ChatSession:
|
||||
f"REMINDER: You currently have {len(memories)} memories stored. "
|
||||
"Use recall to see them."
|
||||
)
|
||||
self.system_messages.append({"role": "developer", "content": "\n".join(dev_parts)})
|
||||
self.system_messages.append({"role": "system", "content": "\n".join(dev_parts)})
|
||||
# Agent prefix: system + developer only (no memories)
|
||||
self._agent_system_messages = list(self.system_messages)
|
||||
|
||||
@@ -971,7 +971,7 @@ class ChatSession:
|
||||
formatted = self._format_messages_for_summary(selected)
|
||||
summary_msgs = [
|
||||
{
|
||||
"role": "developer",
|
||||
"role": "system",
|
||||
"content": (
|
||||
"# Conversation Compactor\n\n"
|
||||
"Your output REPLACES the conversation history — the assistant "
|
||||
@@ -2209,7 +2209,7 @@ class ChatSession:
|
||||
"""Delegate to a general-purpose autonomous sub-agent."""
|
||||
call_id, prompt = item["call_id"], item["prompt"]
|
||||
task_instruction = {
|
||||
"role": "developer",
|
||||
"role": "system",
|
||||
"content": (
|
||||
"# Task Agent\n\n"
|
||||
"You are an autonomous task agent with full tool access. "
|
||||
@@ -2278,7 +2278,7 @@ class ChatSession:
|
||||
break
|
||||
|
||||
agent_messages = list(self._agent_system_messages)
|
||||
agent_messages.append({"role": "developer", "content": self._PLAN_IDENTITY})
|
||||
agent_messages.append({"role": "system", "content": self._PLAN_IDENTITY})
|
||||
agent_messages.extend(prior_plan_msgs)
|
||||
agent_messages.append({"role": "user", "content": prompt})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user