From d349b65713d61a78ed58d4c80d52f3aa592c9064 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Sat, 11 Jul 2026 23:01:12 +0800 Subject: [PATCH] test(agent): remove obsolete runtime context assertions --- tests/agent/test_context_builder.py | 14 ------ tests/agent/test_context_prompt_cache.py | 56 --------------------- tests/agent/test_loop_runner_integration.py | 2 - tests/agent/test_loop_save_turn.py | 1 - tests/agent/test_session_manager_history.py | 17 +------ 5 files changed, 1 insertion(+), 89 deletions(-) diff --git a/tests/agent/test_context_builder.py b/tests/agent/test_context_builder.py index 5d58fc5e..4aa46bd8 100644 --- a/tests/agent/test_context_builder.py +++ b/tests/agent/test_context_builder.py @@ -283,20 +283,6 @@ class TestBuildMessages: messages = builder.build_messages([], "hello", channel="cli", chat_id="direct") user_msg = str(messages[-1]["content"]) assert user_msg == "hello" - assert "Runtime Context" not in user_msg - assert "Current Time:" not in user_msg - assert "Chat ID:" not in user_msg - - def test_session_metadata_does_not_inject_context_without_provider(self, tmp_path): - builder = _builder(tmp_path) - messages = builder.build_messages( - [], - "hi", - channel="cli", - chat_id="x", - session_metadata={"goal_state": {"status": "active", "objective": "hidden"}}, - ) - assert messages[-1]["content"] == "hi" def test_explicit_runtime_context_blocks_are_appended(self, tmp_path): builder = _builder(tmp_path) diff --git a/tests/agent/test_context_prompt_cache.py b/tests/agent/test_context_prompt_cache.py index bbe75265..8d48b237 100644 --- a/tests/agent/test_context_prompt_cache.py +++ b/tests/agent/test_context_prompt_cache.py @@ -62,26 +62,6 @@ def test_system_prompt_reflects_current_dream_memory_contract(tmp_path) -> None: assert "write important facts here" not in prompt -def test_default_user_message_has_no_runtime_context(tmp_path) -> None: - workspace = _make_workspace(tmp_path) - builder = ContextBuilder(workspace) - - messages = builder.build_messages( - history=[], - current_message="Return exactly: OK", - channel="cli", - chat_id="direct", - ) - - assert messages[0]["role"] == "system" - assert "## Current Session" not in messages[0]["content"] - - assert messages[-1]["role"] == "user" - user_content = messages[-1]["content"] - assert user_content == "Return exactly: OK" - assert "_meta" not in messages[-1] - - def test_provider_context_appended_after_user_content(tmp_path) -> None: workspace = _make_workspace(tmp_path) builder = ContextBuilder(workspace) @@ -102,42 +82,6 @@ def test_provider_context_appended_after_user_content(tmp_path) -> None: assert user_pos < context_pos, "user content must precede provider context" -def test_sender_id_is_not_injected_without_provider(tmp_path) -> None: - workspace = _make_workspace(tmp_path) - builder = ContextBuilder(workspace) - - messages = builder.build_messages( - history=[], - current_message="Return exactly: OK", - channel="cli", - chat_id="direct", - sender_id="user-12345", - ) - - user_content = messages[-1]["content"] - assert isinstance(user_content, str) - assert user_content == "Return exactly: OK" - assert "Sender ID:" not in user_content - - -def test_runtime_context_excludes_sender_id_when_not_provided(tmp_path) -> None: - """Sender ID should not be present in runtime context when not provided.""" - workspace = _make_workspace(tmp_path) - builder = ContextBuilder(workspace) - - messages = builder.build_messages( - history=[], - current_message="Return exactly: OK", - channel="cli", - chat_id="direct", - sender_id=None, - ) - - user_content = messages[-1]["content"] - assert isinstance(user_content, str) - assert "Sender ID:" not in user_content - - def test_unprocessed_history_injected_into_system_prompt(tmp_path) -> None: """Entries in history.jsonl not yet consumed by Dream appear with timestamps.""" workspace = _make_workspace(tmp_path) diff --git a/tests/agent/test_loop_runner_integration.py b/tests/agent/test_loop_runner_integration.py index cec77b7e..18092a77 100644 --- a/tests/agent/test_loop_runner_integration.py +++ b/tests/agent/test_loop_runner_integration.py @@ -181,8 +181,6 @@ async def test_runtime_context_is_persisted_as_next_turn_prompt_prefix(tmp_path) assert second_wire[2]["role"] == "assistant" assert second_wire[2]["content"] == "first answer" assert second_wire[3]["content"].startswith("second turn") - assert "Current Time:" not in str(second_wire) - assert "Chat ID:" not in str(second_wire) assert len(provider_calls) == 2 persisted_first_user = session.messages[0] diff --git a/tests/agent/test_loop_save_turn.py b/tests/agent/test_loop_save_turn.py index e6866f06..89d3c581 100644 --- a/tests/agent/test_loop_save_turn.py +++ b/tests/agent/test_loop_save_turn.py @@ -1401,7 +1401,6 @@ async def test_system_subagent_followup_is_persisted_before_prompt_assembly(tmp_ assert "[Message Time:" not in non_system[0]["content"] assert "[Message Time:" not in non_system[1]["content"] assert non_system[2]["content"].count("subagent result") == 1 - assert "Current Time:" not in non_system[2]["content"] assert non_system[2]["content"] == "subagent result" loop.sessions.invalidate("cli:test") diff --git a/tests/agent/test_session_manager_history.py b/tests/agent/test_session_manager_history.py index f00bc787..36f60c89 100644 --- a/tests/agent/test_session_manager_history.py +++ b/tests/agent/test_session_manager_history.py @@ -460,27 +460,12 @@ def test_get_history_does_not_duplicate_persisted_cli_app_runtime_context(): assert public_history == [{"role": "user", "content": "please use @drawio"}] -def test_get_history_does_not_synthesize_mcp_preset_attachment(): - session = Session(key="test:mcp-preset") - session.messages.append({ - "role": "user", - "content": "please use @linear", - "mcp_presets": [{"name": "linear", "transport": "stdio"}], - }) - - assert session.get_history(max_messages=500) == [{ - "role": "user", - "content": "please use @linear", - }] - - -def test_public_history_does_not_synthesize_legacy_capability_context(): +def test_public_history_omits_cli_app_breadcrumb(): session = Session(key="test:legacy-capabilities") session.messages.append({ "role": "user", "content": "please use the attachments", "cli_apps": [{"name": "drawio", "entry_point": "cli-anything-drawio"}], - "mcp_presets": [{"name": "linear", "transport": "stdio"}], }) public_history = session.get_history(