From 9b29e4cb200b082cfb782c4b8fa6c9ce0da703e9 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Tue, 20 Oct 2026 18:07:34 +0100 Subject: [PATCH] fix: scope the dropped-system-message hint to retrieval memories The drop warning told the user to set the memory plugin's 'inject_mode' to one this engine keeps. Only the retrieval memories read inject_mode (BaseRetrievalMemory in ovos-memory-plugins, and the rag memory in this package). The entity and longterm memories always send a system message and have no such option, so the advice sent their users to a setting that does not exist. The hint now names 'allow_system_prompts' first and limits the inject_mode advice to retrieval memories, with the value 'user'. Before the change the new test fails on the old text; after it, all 81 tests pass. Co-Authored-By: Claude Opus 5.5 --- ovos_openai_plugin/chat.py | 7 +++++-- test/test_dropped_system_warning.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ovos_openai_plugin/chat.py b/ovos_openai_plugin/chat.py index b00bd66..bef1c25 100644 --- a/ovos_openai_plugin/chat.py +++ b/ovos_openai_plugin/chat.py @@ -80,8 +80,11 @@ def validate_messages(self, messages: List[AgentMessage]) -> List[AgentMessage]: LOG.warning( f"dropped {len(dropped)} system message(s) before the request: " f"'allow_system_prompts' is off. Context a memory plugin injects as a " - f"system message is discarded with it; set 'allow_system_prompts', or " - f"set the memory plugin's 'inject_mode' to one this engine keeps.") + f"system message is discarded with it; set 'allow_system_prompts', or, " + f"for a retrieval memory (lexical, local-rag, the passages of a " + f"composite, or ovos-openai-rag-memory-plugin), set its 'inject_mode' " + f"to 'user' and move its 'system_prompt' to this engine's " + f"'system_prompt'.") messages = [m for m in messages if m.role != MessageRole.SYSTEM] if not messages: diff --git a/test/test_dropped_system_warning.py b/test/test_dropped_system_warning.py index f0278d2..2664330 100644 --- a/test/test_dropped_system_warning.py +++ b/test/test_dropped_system_warning.py @@ -36,6 +36,17 @@ def test_warns_when_it_drops_a_system_message(): assert "allow_system_prompts" in said and "inject_mode" in said, said +def test_hint_limits_inject_mode_to_retrieval_memories(): + with patch("ovos_openai_plugin.chat.LOG") as log: + _engine().validate_messages(_messages()) + said = " ".join(str(c) for c in log.warning.call_args_list) + assert ("set 'allow_system_prompts', or, for a retrieval memory (lexical, " + "local-rag, the passages of a composite, or ovos-openai-rag-memory-plugin), " + "set its 'inject_mode' to 'user' and move its 'system_prompt' to this " + "engine's 'system_prompt'.") in said, said + assert "one this engine keeps" not in said, said + + def test_warns_once_per_engine(): engine = _engine() with patch("ovos_openai_plugin.chat.LOG") as log: