Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ex_app/lib/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
kyteinsky marked this conversation as resolved.
Resolved
+ user_instructions.strip() + "\n"
)

Expand All @@ -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 (
Expand Down
7 changes: 0 additions & 7 deletions tests/test_user_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading