Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix: Prevent assistant-message prefill rejected by Claude 4.6

0xallame09b5b42c11d
diff --git a/strix/llm/llm.py b/strix/llm/llm.py
index 0cace0ef..507e8c82 100644
--- a/strix/llm/llm.py
+++ b/strix/llm/llm.py
@@ -188,6 +188,9 @@ class LLM:
conversation_history.extend(compressed)
messages.extend(compressed)
+ if messages[-1].get("role") == "assistant":
+ messages.append({"role": "user", "content": "<meta>Continue the task.</meta>"})
+
if self._is_anthropic() and self.config.enable_prompt_caching:
messages = self._add_cache_control(messages)
diff --git a/strix/llm/memory_compressor.py b/strix/llm/memory_compressor.py
index 28730e8d..8cad5107 100644
--- a/strix/llm/memory_compressor.py
+++ b/strix/llm/memory_compressor.py
@@ -91,7 +91,7 @@ def _summarize_messages(
if not messages:
empty_summary = "<context_summary message_count='0'>{text}</context_summary>"
return {
- "role": "assistant",
+ "role": "user",
"content": empty_summary.format(text="No messages to summarize"),
}
@@ -123,7 +123,7 @@ def _summarize_messages(
return messages[0]
summary_msg = "<context_summary message_count='{count}'>{text}</context_summary>"
return {
- "role": "assistant",
+ "role": "user",
"content": summary_msg.format(count=len(messages), text=summary),
}
except Exception: