You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from pathlib import Path
|
|
|
|
from src.ircfa_interaction.memory_policy import (
|
|
contains_sensitive_memory_content,
|
|
is_explicit_memory_request,
|
|
)
|
|
|
|
|
|
def test_explicit_memory_request_requires_a_memory_intent():
|
|
assert is_explicit_memory_request("Please remember that I prefer Indonesian.")
|
|
assert is_explicit_memory_request("Tolong simpan preferensi saya: jawaban ringkas.")
|
|
assert not is_explicit_memory_request("Save this report as a PDF.")
|
|
assert not is_explicit_memory_request("Use Indonesian for this answer.")
|
|
|
|
|
|
def test_sensitive_content_is_not_eligible_for_memory():
|
|
assert contains_sensitive_memory_content("Remember this API key.")
|
|
assert contains_sensitive_memory_content("Simpan password saya.")
|
|
assert not contains_sensitive_memory_content("Remember that I prefer concise answers.")
|
|
|
|
|
|
def test_stream_keeps_memory_policy_after_context_compaction():
|
|
stream_source = Path(__file__).parents[2] / "src" / "ircfa_interaction" / "stream2.py"
|
|
source = stream_source.read_text()
|
|
|
|
# One import and two prompt-build paths: normal and after compaction.
|
|
assert source.count("MEMORY_POLICY_INSTRUCTIONS") >= 3
|