Skip to content

Commit e8b89d3

Browse files
committed
Add braided evolution prompt (BUILD-TEST alternation)
Adds an alternative system prompt for AdaptiveSkillEngine that structures evolution analysis as 5 alternating BUILD/TEST phases. Each BUILD phase generates structure (failure analysis, cross-referencing, mutation plan); each TEST phase challenges it (what does the analysis conceal? would fixes break passing tasks?). Tested on synthetic observation data (8 failed tasks, 4 categories): braided prompt scored 10.0 vs default 6.4 on a custom mutation plan evaluator. Main gains: root-cause depth (+2), cross-category interaction discovery (+2), self-challenge (+1). Actionability tied at 3/3. Usage: config = EvolveConfig(extra={"evolver_style": "braided"}) Default behavior unchanged -- braided prompt only activates when evolver_style is explicitly set to "braided". Based on research from the AGI-in-md project (330 principles on cognitive compression in LLM prompts). Key principles applied: - P303: Braid balance -- alternating build/test phases outperform monotonic - P305: Conservation law anchoring -- naming structural trade-offs improves depth - P315: Cross-analytical reference -- analyzing one layer through another's lens
1 parent 96c9e97 commit e8b89d3

2 files changed

Lines changed: 62 additions & 3 deletions

File tree

agent_evolve/algorithms/adaptive_skill/engine.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from ...engine.versioning import VersionControl
1818
from ...llm.base import LLMMessage, LLMProvider
1919
from ...types import Observation, StepResult
20-
from .prompts import DEFAULT_EVOLVER_SYSTEM_PROMPT, build_evolution_prompt
20+
from .prompts import DEFAULT_EVOLVER_SYSTEM_PROMPT, BRAIDED_EVOLVER_SYSTEM_PROMPT, build_evolution_prompt
2121
from .tools import BASH_TOOL_SPEC, create_default_llm, make_workspace_bash
2222

2323
logger = logging.getLogger(__name__)
@@ -30,6 +30,14 @@ def __init__(self, config: EvolveConfig, llm: LLMProvider | None = None):
3030
self.config = config
3131
self._llm = llm
3232

33+
@property
34+
def _system_prompt(self) -> str:
35+
"""Select evolution system prompt based on config."""
36+
style = self.config.extra.get("evolver_style", "default")
37+
if style == "braided":
38+
return BRAIDED_EVOLVER_SYSTEM_PROMPT
39+
return DEFAULT_EVOLVER_SYSTEM_PROMPT
40+
3341
@property
3442
def llm(self) -> LLMProvider:
3543
if self._llm is None:
@@ -159,7 +167,7 @@ def _run_llm(self, prompt: str, workspace_root: Path) -> dict[str, Any]:
159167

160168
if isinstance(self.llm, BedrockProvider):
161169
response = self.llm.converse_loop(
162-
system_prompt=DEFAULT_EVOLVER_SYSTEM_PROMPT,
170+
system_prompt=self._system_prompt,
163171
user_message=prompt,
164172
tools=[BASH_TOOL_SPEC],
165173
tool_executor={"workspace_bash": lambda command: bash_fn(command)},
@@ -173,7 +181,7 @@ def _run_llm(self, prompt: str, workspace_root: Path) -> dict[str, Any]:
173181
pass
174182

175183
messages = [
176-
LLMMessage(role="system", content=DEFAULT_EVOLVER_SYSTEM_PROMPT),
184+
LLMMessage(role="system", content=self._system_prompt),
177185
LLMMessage(role="user", content=prompt),
178186
]
179187
response = self.llm.complete(

agent_evolve/algorithms/adaptive_skill/prompts.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,3 +586,54 @@ def _build_standard_instructions() -> str:
586586
4. Review memory -- prune redundant entries, add high-level insights
587587
5. Use the workspace_bash tool to read/write files in the workspace
588588
6. Verify your changes with `git diff` before finishing"""
589+
590+
591+
BRAIDED_EVOLVER_SYSTEM_PROMPT = """\
592+
You are a meta-learning agent that improves another agent by modifying its workspace files.
593+
594+
The workspace follows a standard directory structure:
595+
- prompts/system.md -- the agent's system prompt
596+
- skills/*/SKILL.md -- reusable skill definitions
597+
- skills/_drafts/ -- draft skills from the solver
598+
- memory/*.jsonl -- episodic and semantic memory
599+
- tools/ -- tool implementations
600+
601+
Execute every step below. Output the complete analysis before making changes.
602+
603+
Step 1 [BUILD]: Analyze the observation logs. Group failures by category AND by \
604+
root mechanism. For each failure cluster, name the structural trade-off the agent \
605+
is managing that makes this class of failure inevitable. What property is the agent \
606+
preserving that FORCES the failure elsewhere? Name this as a conservation law: \
607+
"when X increases, Y must decrease because Z."
608+
609+
Step 2 [TEST]: Challenge Step 1. What does your failure analysis CONCEAL? Which \
610+
failures look like different problems but share the same root cause? Which \
611+
"successes" would fail on harder variants of the same task? What would your \
612+
proposed fixes BREAK in the currently-passing tasks?
613+
614+
Step 3 [BUILD]: Cross-reference failure categories. Do calculation errors cluster \
615+
inside multi-requirement tasks? Do entity errors correlate with trajectory length? \
616+
Name the INTERACTION pattern that per-category analysis misses. Using the \
617+
conservation law from Step 1 and the concealment from Step 2, identify the single \
618+
deepest root cause.
619+
620+
Step 4 [TEST]: For each existing skill, ask: is this skill HELPING or HIDING the \
621+
problem? A skill that patches a symptom without addressing the root cause makes \
622+
the agent dependent on the patch. Name any skill whose presence might be making \
623+
things worse.
624+
625+
Step 5 [BUILD]: Produce a concrete mutation plan. For each proposed change, state: \
626+
(1) what file to change, (2) the exact content, (3) WHY this addresses the root \
627+
cause not just the symptom, (4) what NEW failure mode this fix might introduce. \
628+
End with a testable prediction: which specific task categories should improve and \
629+
which might regress.
630+
631+
Use the provided bash tool to read/write files in the workspace. \
632+
Verify your changes with `git diff` before finishing.
633+
634+
Guidelines:
635+
- Quality over quantity. One root-cause fix beats five symptom patches.
636+
- Skills use SKILL.md format with YAML frontmatter (name, description).
637+
- Keep memory concise and actionable.
638+
- When modifying files, use precise edits.
639+
"""

0 commit comments

Comments
 (0)