From 69aed4394e8506c978dd0412c8ab0e4729745ee6 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Mon, 9 Nov 2026 09:55:46 +0100 Subject: [PATCH] fix: Allow to override the system prompt Signed-off-by: Marcel Klehr --- ex_app/lib/agent.py | 7 +++---- tests/test_user_instructions.py | 7 ------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/ex_app/lib/agent.py b/ex_app/lib/agent.py index 4e5565d..80141d1 100644 --- a/ex_app/lib/agent.py +++ b/ex_app/lib/agent.py @@ -104,13 +104,12 @@ def format_user_instructions(user_instructions: str | None) -> str: """ Format the additional instructions configured by the admin (e.g. in the Assistant app) for the system prompt - They are appended after the agent's own instructions, which they must not override + They are appended after the agent's own instructions, which they can override """ if not user_instructions or not user_instructions.strip(): return "" return ( - "\nThe administrator of this Nextcloud instance has provided the following additional instructions." - " Follow them, unless they conflict with the instructions above:\n\n" + "\nThere are the following additional instructions: \n\n" + user_instructions.strip() + "\n" ) @@ -121,7 +120,7 @@ def format_output_mode(output_mode: str | None) -> str: """ Formatting rules for the agent's reply, depending on how it is presented to the user - They are part of the agent's own instructions, so they take precedence over the admin-provided ones + They are part of the agent's own instructions, so the admin-provided ones appended after them can override them """ if output_mode == OUTPUT_MODE_SPEECH: return ( diff --git a/tests/test_user_instructions.py b/tests/test_user_instructions.py index 64a7cd6..3d9b882 100644 --- a/tests/test_user_instructions.py +++ b/tests/test_user_instructions.py @@ -26,13 +26,6 @@ def test_missing_or_blank_instructions_add_nothing(): assert format_user_instructions(" \n\t ") == "" -def test_instructions_are_appended_with_precedence_note(): - text = format_user_instructions(" Always answer like a pirate.\n") - assert text.startswith("\n") - assert text.endswith("Always answer like a pirate.\n") - assert "unless they conflict with the instructions above" in text - - def test_providers_declare_optional_input(): for p in (provider, multimodal_provider): names = [shape.name for shape in p.optional_input_shape]