From 6fb5e7cde33ed9f9c10eec4ecbe5377fa3b4f713 Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Thu, 23 Jul 2026 18:47:10 -0700 Subject: [PATCH] Tune general task execution guidance --- src/context_system/prompt_assembly.py | 24 +++++++++++++++++++++++- tests/test_system_prompt_full.py | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/context_system/prompt_assembly.py b/src/context_system/prompt_assembly.py index e64adce0..13d67a7e 100644 --- a/src/context_system/prompt_assembly.py +++ b/src/context_system/prompt_assembly.py @@ -883,12 +883,29 @@ def _emit_group( "the error, check your assumptions, try a focused fix. Don't retry " "the identical action blindly, but don't abandon a viable approach " "after a single failure either.\n" + "- For ambiguous bugs, failures, or unfamiliar data, form a small set " + "of plausible hypotheses from the available evidence and rank them by " + "likelihood and the cost of checking them. Start with the cheapest " + "check that can distinguish among the leading hypotheses. Broaden the " + "investigation only when results rule them out or reveal new evidence; " + "do not replace focused diagnosis with an exhaustive search of the " + "environment.\n" "- Before finishing, audit the result against every explicit requirement " "in the user's request and verify the requirements that can be checked. " "Do not treat producing a plausible result as proof that the task is " "complete. When the user asks for all, every, multiple, or an exhaustive " "set of results, actively search for additional valid results instead of " "stopping after the first one.\n" + "- Use the narrowest sufficient verification for the change. Prefer an " + "existing focused check, add a regression test when it provides lasting " + "value, and run broader checks when the scope or risk warrants them. " + "Do not create multiple temporary tests or repeat equivalent checks once " + "the same behavior has been established.\n" + "- Stop when the explicit requirements are satisfied and proportionate " + "verification has passed. Do not re-run passing checks or expand into " + "unrequested audits without concrete evidence of an unresolved " + "requirement, a new failure, or material risk. If verification is not " + "possible, state that clearly instead of continuing speculative work.\n" "- Be cautious not to introduce security vulnerabilities such as " "command injection, XSS, SQL injection, and other OWASP top 10 " "vulnerabilities.\n" @@ -905,7 +922,12 @@ def _emit_group( "- Don't create helpers, utilities, or abstractions for one-time " "operations. Don't design for hypothetical future requirements. " "The right amount of complexity is what the task actually requires. " - "Three similar lines of code is better than a premature abstraction." + "Three similar lines of code is better than a premature abstraction.\n" + "- When the same well-understood mechanical change is needed in multiple " + "places, inspect the affected scope and make a coherent grouped edit " + "when it is safe and reviewable. Avoid a long sequence of tiny edits " + "with equivalent verification after each one. Keep unrelated or " + "semantically distinct changes separate." ) # Module 4: Cautious operations diff --git a/tests/test_system_prompt_full.py b/tests/test_system_prompt_full.py index 8c083778..a180305e 100644 --- a/tests/test_system_prompt_full.py +++ b/tests/test_system_prompt_full.py @@ -65,6 +65,28 @@ def test_task_prompt_requires_requirement_audit_and_exhaustive_results(self): assert "all, every, multiple, or an exhaustive set" in prompt assert "stopping after the first one" in prompt + def test_task_prompt_prioritizes_evidence_and_cheap_discriminating_checks(self): + prompt = build_full_system_prompt(use_cache=False) + assert "small set of plausible hypotheses" in prompt + assert "cheapest check that can distinguish" in prompt + assert "Broaden the investigation only when results rule them out" in prompt + assert "exhaustive search of the environment" in prompt + + def test_task_prompt_uses_proportionate_verification_and_stops(self): + prompt = build_full_system_prompt(use_cache=False) + assert "narrowest sufficient verification" in prompt + assert "Do not create multiple temporary tests" in prompt + assert "Stop when the explicit requirements are satisfied" in prompt + assert "Do not re-run passing checks" in prompt + assert "material risk" in prompt + + def test_task_prompt_groups_related_mechanical_edits(self): + prompt = build_full_system_prompt(use_cache=False) + assert "same well-understood mechanical change" in prompt + assert "coherent grouped edit" in prompt + assert "long sequence of tiny edits" in prompt + assert "Keep unrelated or semantically distinct changes separate" in prompt + def test_identity_prompt_backward_compat(self): """_IDENTITY_PROMPT is an alias for _INTRO_SECTION.""" assert _IDENTITY_PROMPT is _INTRO_SECTION