# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from artemis.agents.operator.prompt_builder import ( OperatorPromptBuilder, load_operator_prompts, ) from artemis.agents.operator.prompts import apply_operator_prompt_contract def test_operator_prompt_contract_matches_note_runtime_semantics(): prompt = apply_operator_prompt_contract(load_operator_prompts()["main_template"]) assert "write-through tools `update_note` and `append_note`" in prompt assert "may accompany at most one Turn-Ending Action" in prompt assert "`read_note`, `list_notes`, `save_note`, and `recall_history`" in prompt assert "Do NOT submit a Turn-Ending Action at the same time" not in prompt assert "memory note tools (`read_note`, `list_notes`, `save_note`, `update_note`" not in prompt def test_operator_prompt_is_single_template_without_checker_dialogue(): """The prompt is never switched by verification results: main_template is the only template, and no checker-dialogue machinery is advertised.""" prompts = load_operator_prompts() assert set(prompts) == {"main_template"} prompt = apply_operator_prompt_contract(prompts["main_template"]) assert "reply_to_checker" not in prompt assert "Checker" not in prompt def test_operator_prompt_omits_environment_trust_and_explorer_directives(): for template in load_operator_prompts().values(): prompt = apply_operator_prompt_contract(template) assert "Untrusted Screen Content & Instruction Priority" not in prompt assert "Visual Explorer Rule" not in prompt def test_operator_prompt_keeps_large_list_traversal_single_pass_until_boundary(): for template in load_operator_prompts().values(): prompt = apply_operator_prompt_contract(template) assert "do not advance to another milestone or mark it complete" in prompt assert "A single scroll that reveals no new content is not sufficient evidence" in prompt assert "one additional successful swipe in the same direction" in prompt assert "never reverse direction merely to prove completion" in prompt assert "even if older execution history has been pruned" in prompt assert "Terminate exploration when a definitive boundary is reached" not in prompt def test_compatibility_builder_uses_canonical_operator_template(): expected = apply_operator_prompt_contract(load_operator_prompts()["main_template"]) assert OperatorPromptBuilder.build_system_message() == expected assert "wait_for_delay(seconds=" not in expected assert 'press_key(key="home"' not in expected