test: remove obsolete nonexistence checks
This commit is contained in:
1 parent
c08172a641
commit
3495281282
24 files changed
+8
-407
No files matched your search
@@ -9,7 +9,6 @@ def test_weather_skill_uses_windows_safe_single_today_request() -> None:
|
||||
assert "bare `curl` may resolve to `Invoke-WebRequest`" in normalized
|
||||
assert "https://wttr.in/London?1&m" in content
|
||||
assert 'curl.exe -s "https://wttr.in/Berlin.png" -o weather.png' in content
|
||||
assert "/tmp/weather.png" not in content
|
||||
assert (
|
||||
"Do not fetch current conditions separately when a today or forecast "
|
||||
"request already includes them."
|
||||
|
||||
@@ -218,17 +218,14 @@ class TestBundledToolContract:
|
||||
assert "Do not use `exec` as a universal workaround" in content
|
||||
assert "## File and Coding Workflows" in content
|
||||
assert "`grep` returns matches with five context lines by default" in content
|
||||
assert 'defaults to `output_mode="files_with_matches"`' not in content
|
||||
assert "apply_patch" in content
|
||||
assert "acceptance criteria into concrete checks" in content
|
||||
assert "visual evidence reaches the model" in content
|
||||
assert "clear user request as authorization" in content
|
||||
assert "Never invent missing records or measurements" in content
|
||||
assert "scientific fitting" not in content
|
||||
assert "## Web and External Information" in content
|
||||
assert "## Messaging and Media" in content
|
||||
assert "## Scheduling and Background Work" in content
|
||||
assert "pure coding" not in content.lower()
|
||||
|
||||
def test_tool_contract_is_injected_without_workspace_file(self, tmp_path):
|
||||
builder = _builder(tmp_path)
|
||||
|
||||
@@ -80,8 +80,6 @@ def test_system_prompt_reflects_current_dream_memory_contract(tmp_path) -> None:
|
||||
assert "memory/history.jsonl" in prompt
|
||||
assert "automatically managed by Dream" in prompt
|
||||
assert "do not edit directly" in prompt
|
||||
assert "memory/HISTORY.md" not in prompt
|
||||
assert "write important facts here" not in prompt
|
||||
|
||||
|
||||
def test_provider_context_appended_after_user_content(tmp_path) -> None:
|
||||
@@ -137,28 +135,6 @@ def test_execution_rules_reach_existing_workspace_soul(tmp_path) -> None:
|
||||
assert soul_path.read_text(encoding="utf-8") == legacy_soul
|
||||
|
||||
|
||||
def test_identity_has_no_behavioral_instructions(tmp_path) -> None:
|
||||
"""Identity template should not contain behavioral rules or hardcoded name."""
|
||||
workspace = _make_workspace(tmp_path)
|
||||
builder = ContextBuilder(workspace)
|
||||
|
||||
identity = builder._get_identity(channel=None)
|
||||
assert "You are nanobot" not in identity
|
||||
assert "Act, don't narrate" not in identity
|
||||
assert "Execution Rules" not in identity
|
||||
|
||||
|
||||
def test_system_prompt_does_not_warn_about_message_time_markers(tmp_path) -> None:
|
||||
"""Parroting is prevented by not annotating assistant turns in history;
|
||||
no prompt-level warning about ``[Message Time: ...]`` is needed."""
|
||||
workspace = _make_workspace(tmp_path)
|
||||
builder = ContextBuilder(workspace)
|
||||
|
||||
prompt = builder.build_system_prompt()
|
||||
|
||||
assert "Message Time" not in prompt
|
||||
|
||||
|
||||
def test_default_soul_template_keeps_execution_policy_in_tool_contract() -> None:
|
||||
"""SOUL owns personality while the always-injected contract owns execution policy."""
|
||||
soul = (pkg_files("nanobot") / "templates" / "SOUL.md").read_text(encoding="utf-8")
|
||||
@@ -256,7 +232,6 @@ def test_fresh_workspace_omits_default_prompt_scaffolding(tmp_path) -> None:
|
||||
assert "## USER.md" not in prompt
|
||||
assert "8281248569" not in prompt
|
||||
assert "(your name)" not in prompt
|
||||
assert "apt/brew" not in prompt
|
||||
assert prompt.count("Do not use the 'message' tool for normal replies") == 1
|
||||
|
||||
|
||||
|
||||
@@ -264,7 +264,6 @@ def test_refresh_clears_preset_when_new_default_has_same_snapshot_signature() ->
|
||||
assert refreshed is not None
|
||||
assert resolver.model_preset is None
|
||||
assert resolver.runtime.model_preset is None
|
||||
assert "_active_preset" not in resolver.__dict__
|
||||
|
||||
|
||||
def test_resolver_refreshes_provider_generation_for_next_default_turn() -> None:
|
||||
|
||||
@@ -29,7 +29,7 @@ def _provider(default_model: str, max_tokens: int = 123) -> MagicMock:
|
||||
return provider
|
||||
|
||||
|
||||
def test_provider_refresh_updates_only_runtime_resolver(tmp_path: Path) -> None:
|
||||
def test_provider_refresh_updates_runtime_resolver(tmp_path: Path) -> None:
|
||||
old_provider = _provider("old-model")
|
||||
new_provider = _provider("new-model", max_tokens=456)
|
||||
loop = AgentLoop(
|
||||
@@ -53,36 +53,6 @@ def test_provider_refresh_updates_only_runtime_resolver(tmp_path: Path) -> None:
|
||||
assert loop.provider is new_provider
|
||||
assert loop.model == "new-model"
|
||||
assert loop.context_window_tokens == 2000
|
||||
assert not hasattr(loop.runner, "provider")
|
||||
assert not hasattr(loop.subagents, "provider")
|
||||
assert not hasattr(loop.subagents, "model")
|
||||
assert not hasattr(loop.subagents.runner, "provider")
|
||||
assert not hasattr(loop.consolidator, "provider")
|
||||
assert not hasattr(loop.consolidator, "model")
|
||||
assert not hasattr(loop.consolidator, "context_window_tokens")
|
||||
assert not hasattr(loop.consolidator, "max_completion_tokens")
|
||||
|
||||
|
||||
def test_loop_has_no_mutable_runtime_mirrors_or_legacy_snapshot_api(tmp_path: Path) -> None:
|
||||
loop = AgentLoop(
|
||||
bus=MessageBus(),
|
||||
provider=_provider("test-model"),
|
||||
workspace=tmp_path,
|
||||
model="test-model",
|
||||
context_window_tokens=1000,
|
||||
)
|
||||
|
||||
assert {
|
||||
"provider",
|
||||
"model",
|
||||
"context_window_tokens",
|
||||
"model_presets",
|
||||
"_active_preset",
|
||||
"_provider_signature",
|
||||
"_max_messages",
|
||||
}.isdisjoint(loop.__dict__)
|
||||
assert not hasattr(loop, "_apply_provider_snapshot")
|
||||
assert not hasattr(loop, "_build_model_preset_snapshot")
|
||||
|
||||
|
||||
def test_llm_runtime_refreshes_provider_snapshot(tmp_path: Path) -> None:
|
||||
@@ -108,7 +78,6 @@ def test_llm_runtime_refreshes_provider_snapshot(tmp_path: Path) -> None:
|
||||
assert runtime.provider is new_provider
|
||||
assert runtime.model == "new-model"
|
||||
assert loop.provider is new_provider
|
||||
assert not hasattr(loop.runner, "provider")
|
||||
|
||||
|
||||
def test_llm_runtime_surfaces_invalidated_config_errors(tmp_path: Path) -> None:
|
||||
|
||||
@@ -69,12 +69,8 @@ def test_model_preset_setter_updates_state(tmp_path) -> None:
|
||||
assert runtime.generation.temperature == 0.5
|
||||
assert runtime.generation.max_tokens == 4096
|
||||
assert runtime.generation.reasoning_effort == "low"
|
||||
assert not hasattr(loop.subagents, "model")
|
||||
assert not hasattr(loop.consolidator, "model")
|
||||
assert not hasattr(loop.consolidator, "context_window_tokens")
|
||||
assert loop.llm_runtime().model == "openai/gpt-4.1"
|
||||
assert loop.llm_runtime().context_window_tokens == 32_768
|
||||
assert not hasattr(loop.consolidator, "max_completion_tokens")
|
||||
assert loop.llm_runtime().generation.max_tokens == 4096
|
||||
|
||||
|
||||
@@ -122,13 +118,8 @@ def test_model_preset_setter_replaces_provider_from_snapshot(tmp_path) -> None:
|
||||
loop.set_model_preset("deep")
|
||||
|
||||
assert loop.provider is new_provider
|
||||
assert not hasattr(loop.runner, "provider")
|
||||
assert not hasattr(loop.subagents, "provider")
|
||||
assert not hasattr(loop.subagents.runner, "provider")
|
||||
assert not hasattr(loop.consolidator, "provider")
|
||||
assert loop.model == "anthropic/claude-opus-4-5"
|
||||
assert loop.context_window_tokens == 200_000
|
||||
assert not hasattr(loop.consolidator, "max_completion_tokens")
|
||||
assert loop.llm_runtime().generation.max_tokens == 2048
|
||||
|
||||
|
||||
@@ -151,10 +142,7 @@ def test_model_preset_setter_failure_leaves_old_state(tmp_path) -> None:
|
||||
|
||||
assert loop.model_preset is None
|
||||
assert loop.model == "base-model"
|
||||
assert not hasattr(loop.subagents, "model")
|
||||
assert not hasattr(loop.consolidator, "model")
|
||||
assert loop.context_window_tokens == 1000
|
||||
assert not hasattr(loop.consolidator, "max_completion_tokens")
|
||||
assert loop.llm_runtime().generation.max_tokens == 123
|
||||
|
||||
|
||||
|
||||
@@ -102,20 +102,6 @@ class TestSubagentStatus:
|
||||
assert s.error is None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Runtime ownership
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestRuntimeOwnership:
|
||||
def test_manager_has_no_provider_model_mirrors(self, tmp_path):
|
||||
sm = _manager(tmp_path)
|
||||
assert not hasattr(sm, "provider")
|
||||
assert not hasattr(sm, "model")
|
||||
assert not hasattr(sm, "context_window_tokens")
|
||||
assert not hasattr(sm.runner, "provider")
|
||||
|
||||
|
||||
class TestLegacyCompatibility:
|
||||
def test_accepts_exported_legacy_constructor_positionally(self, tmp_path):
|
||||
provider = MagicMock(spec=LLMProvider)
|
||||
@@ -132,8 +118,6 @@ class TestLegacyCompatibility:
|
||||
|
||||
assert sm.workspace == tmp_path
|
||||
assert sm.max_tool_result_chars == 16_000
|
||||
assert not hasattr(sm, "provider")
|
||||
assert not hasattr(sm, "model")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_legacy_spawn_captures_runtime_at_admission(self, tmp_path):
|
||||
|
||||
@@ -45,7 +45,6 @@ def test_agent_loop_assembles_my_tool_with_runtime_control(tmp_path: Path) -> No
|
||||
assert isinstance(tool._runtime_control, RuntimeControl)
|
||||
assert isinstance(tool._runtime_control, AgentRuntimeControl)
|
||||
assert tool._runtime_control is not loop
|
||||
assert not hasattr(tool, "_runtime_state")
|
||||
|
||||
|
||||
def test_runtime_snapshot_has_exact_allowlist_and_redacts_secrets(tmp_path: Path) -> None:
|
||||
|
||||
Reference in new issue
Block a user