diff --git a/tests/test_describe_config.py b/tests/test_describe_config.py index 1c2db4420..6c5d53050 100644 --- a/tests/test_describe_config.py +++ b/tests/test_describe_config.py @@ -3,8 +3,11 @@ """Tests for observe/describe.py category discovery and configuration.""" +from pathlib import Path + from solstone.observe import describe as describe_module from solstone.observe.describe import _build_redact_instruction +from solstone.think.prompts import load_prompt def test_categories_discovered(): @@ -57,11 +60,27 @@ def test_extractable_categories_have_prompts(): def test_category_max_output_token_defaults_and_overrides(): """Test category output-token defaults and explicit overrides.""" - CATEGORIES = describe_module.CATEGORIES - - assert CATEGORIES["browsing"]["max_output_tokens"] == 4096 - assert CATEGORIES["messaging"]["max_output_tokens"] == 8192 - assert CATEGORIES["calendar"]["max_output_tokens"] == 8192 + categories_dir = Path(describe_module.__file__).resolve().parent / "categories" + declared_overrides = [] + defaulted_categories = [] + + for md_path in categories_dir.glob("*.md"): + category = md_path.stem + prompt_content = load_prompt(category, base_dir=categories_dir) + metadata = describe_module.CATEGORIES[category] + + if "max_output_tokens" in prompt_content.metadata: + declared_overrides.append(category) + assert ( + metadata["max_output_tokens"] + == prompt_content.metadata["max_output_tokens"] + ) + else: + defaulted_categories.append(category) + assert metadata["max_output_tokens"] == 4096 + + assert declared_overrides + assert defaulted_categories def test_categorization_prompt_built(): diff --git a/tests/test_screen_formatter.py b/tests/test_screen_formatter.py index ab415480b..090742a51 100644 --- a/tests/test_screen_formatter.py +++ b/tests/test_screen_formatter.py @@ -438,15 +438,18 @@ def test_format_screen_uses_meeting_formatter(): def test_format_screen_falls_back_for_missing_formatter(): """Test that categories without .py formatter use default formatting.""" + category = "nonexistent_category" frames = [ { "timestamp": 0, "analysis": { - "primary": "browsing", - "visual_description": "Web page", + "primary": category, + "visual_description": "Synthetic category content", }, "content": { - "browsing": "# Example Page\n\nVisible text", + # Synthetic category ensures no real category can grow a formatter + # and accidentally stop exercising _load_category_formatter -> None. + category: "# Example Page\n\nVisible text", }, }, ] @@ -457,7 +460,7 @@ def test_format_screen_falls_back_for_missing_formatter(): markdown = chunks[0]["markdown"] # Should use default text formatting - assert "**Browsing:**" in markdown + assert "**Nonexistent_Category:**" in markdown assert "# Example Page" in markdown