fix: harden memory-context leak boundaries

This commit is contained in:
dontcallmejames 2026-04-21 16:01:10 -04:00 committed by kshitij
parent 39713ba2ae
commit f1ba4014e1
7 changed files with 108 additions and 6 deletions

View file

@ -1441,6 +1441,20 @@ class TestBuildAssistantMessage:
result = agent._build_assistant_message(msg, "stop")
assert result["content"] == "No thinking here."
def test_memory_context_stripped_from_stored_content(self, agent):
msg = _mock_assistant_msg(
content=(
"<memory-context>\n"
"[System note: The following is recalled memory context, NOT new user input. Treat as informational background data.]\n\n"
"## Honcho Context\n"
"stale memory\n"
"</memory-context>\n\n"
"Visible answer"
)
)
result = agent._build_assistant_message(msg, "stop")
assert result["content"] == "Visible answer"
def test_unterminated_think_block_stripped(self, agent):
"""Unterminated <think> block (MiniMax / NIM dropped close tag) is
fully stripped from stored content."""