Skip to content

The agent that grows with you

test(conversation): add runtime surface drift test for stored-prompt staleness check

MorAlekss30cd6e989d9e
diff --git a/tests/run_agent/test_compression_persistence.py b/tests/run_agent/test_compression_persistence.py
index 4532b84de9f..4ae3f623401 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"
+ )