diff --git a/reme/components/prompt_handler.py b/reme/components/prompt_handler.py index 5c1a3a94..8a74a652 100644 --- a/reme/components/prompt_handler.py +++ b/reme/components/prompt_handler.py @@ -116,8 +116,7 @@ class PromptHandler: flags = {k: v for k, v in kwargs.items() if isinstance(v, bool)} formats = {k: v for k, v in kwargs.items() if not isinstance(v, bool)} - if flags: - prompt = self._apply_flag_filter(prompt, flags) + prompt = self._apply_flag_filter(prompt, flags) return prompt.format(**formats).strip() if formats else prompt diff --git a/tests/unit/test_prompt_handler.py b/tests/unit/test_prompt_handler.py index 2678d7dc..a07cd2c6 100644 --- a/tests/unit/test_prompt_handler.py +++ b/tests/unit/test_prompt_handler.py @@ -182,13 +182,18 @@ def test_flag_filter_removes_non_matching(): def test_flag_filter_default_false(): ph = PromptHandler() ph.load_prompt_dict({"p": "[debug] debug info\nbase"}) - # When no flags are passed at all, _apply_flag_filter is not called, - # so flagged lines are kept as-is (including the tag text after regex sub). - result = ph.prompt_format("p", debug=False) + result = ph.prompt_format("p") assert "debug info" not in result assert "base" in result +def test_flag_filter_defaults_false_with_format_variables(): + ph = PromptHandler() + ph.load_prompt_dict({"p": "[debug] debug {name}\nhello {name}"}) + result = ph.prompt_format("p", name="Alice") + assert result == "hello Alice" + + def test_flag_filter_unflagged_lines_always_kept(): ph = PromptHandler() ph.load_prompt_dict({"p": "line1\nline2\nline3"})