From 30cd6e989d9e643d411b94823339dbe225e52167 Mon Sep 17 00:00:00 2001 From: MorAlekss Date: Wed, 17 Jun 2026 07:47:39 -0700 Subject: [PATCH] test(conversation): add runtime surface drift test for stored-prompt staleness check --- .../run_agent/test_compression_persistence.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/run_agent/test_compression_persistence.py b/tests/run_agent/test_compression_persistence.py index 4532b84de9f3..4ae3f623401d 100644 --- a/tests/run_agent/test_compression_persistence.py +++ b/tests/run_agent/test_compression_persistence.py @@ -485,3 +485,21 @@ class TestStoredPromptCwdDrift: assert _stored_prompt_matches_runtime(agent, stored_prompt) is True, ( "Expected True when stored cwd matches current cwd" ) + + def test_stored_prompt_stale_when_runtime_surface_differs(self): + """Desktop GUI marker in stored prompt must not be reused when running in terminal.""" + from unittest.mock import patch + from agent.conversation_loop import _stored_prompt_matches_runtime + + agent = self._make_agent() + stored_prompt = ( + "Runtime surface: you're running inside the Hermes desktop GUI app.\n" + "Model: test/model\n" + "Provider: openrouter\n" + ) + + # Current runtime is terminal/CLI: no desktop marker. + with patch.dict(os.environ, {"HERMES_DESKTOP": ""}, clear=False): + assert _stored_prompt_matches_runtime(agent, stored_prompt) is False, ( + "Expected False when stored prompt claims desktop but HERMES_DESKTOP is unset" + )