Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/context_system/prompt_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tests/test_system_prompt_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading