fix: strip leaked memory context from commentary

This commit is contained in:
dontcallmejames
2026-04-18 13:27:25 -04:00
committed by kshitij
parent dad0217450
commit 39713ba2ae
2 changed files with 25 additions and 1 deletions

View File

@@ -1115,6 +1115,30 @@ def test_interim_commentary_is_not_marked_already_streamed_when_stream_callback_
}
def test_interim_commentary_strips_leaked_memory_context(monkeypatch):
agent = _build_agent(monkeypatch)
observed = {}
agent.interim_assistant_callback = lambda text, *, already_streamed=False: observed.update(
{"text": text, "already_streamed": already_streamed}
)
leaked = (
"<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"
"I'll inspect the repo structure first."
)
agent._emit_interim_assistant_message({"role": "assistant", "content": leaked})
assert observed == {
"text": "I'll inspect the repo structure first.",
"already_streamed": False,
}
def test_run_conversation_codex_continues_after_commentary_phase_message(monkeypatch):
agent = _build_agent(monkeypatch)
responses = [