Skip to content

feat(prompts): add prompt-section evolution pipeline - #180

Open
ideas24h wants to merge 2 commits into
NousResearch:mainfrom
ideas24h:feat/phase3-prompt-section-evolution
Open

ideas24h wants to merge 2 commits into
NousResearch:mainfrom
ideas24h:feat/phase3-prompt-section-evolution

Conversation

@ideas24h

Copy link
Copy Markdown

Summary

  • Adds Phase 3 prompt-section evolution for named constants in agent/prompt_builder.py.
  • Adds static AST prompt-section loader and DSPy PromptSectionModule.
  • Adds CLI: python -m evolution.prompts.evolve_prompt_section --section MEMORY_GUIDANCE ...
  • Hardens synthetic dataset JSON parsing and tool-description evolution artifacts from the Phase 2 work.
  • Adds run_long_loop.sh for longer Phase 1 + Phase 2 loops.

Validation

  • pytest tests -q: 149 passed
  • Dry run: python -m evolution.prompts.evolve_prompt_section --section MEMORY_GUIDANCE --hermes-repo /home/raul/.hermes/hermes-agent --dry-run
  • Smoke run: MEMORY_GUIDANCE, 2 iterations, gpt-4.1-nano eval; output saved locally under output/prompts/MEMORY_GUIDANCE/20260825_103331/

Note: upstream merge permissions are not available to ideas24h, so this PR is published for maintainer merge.

…description evolution

Phase 1 (skill evolution) was non-functional against the installed dspy 3.3.1:
- dspy.GEPA(max_steps=...) — param renamed upstream to auto/max_full_evals/
  max_metric_calls; also never wired optimizer_model into a reflection_lm
- skill_fitness_metric only accepted 3 args; GEPA requires the 5-arg
  (gold, pred, trace, pred_name, pred_trace) signature — wired it to the
  existing but unused LLMJudge instead of the crude keyword-overlap heuristic
- constraint validation ran against the skill body (frontmatter stripped),
  so skill_structure could never pass — now validates the reassembled file
- most severe: SkillModule stored skill_text as a plain attribute while GEPA
  only mutates predictor instructions, so the exported "evolved" skill was
  always byte-identical to baseline despite a real score improvement. Skill
  text is now the predictor's instructions directly, so it's live-read off
  the mutated signature.
- external_importers' Hermes session reader crashed on any non-UTF8 file
  under ~/.hermes/sessions/

Verified end to end: github-code-review +22.7% (synthetic), +2.1% (sessiondb,
mining real Claude Code/Hermes usage); systematic-debugging -5.8% (Gemini) —
a genuine regression, GEPA over-compressed and lost substance.

Phase 2 (tool description evolution) didn't exist upstream — built
evolution/tools/tool_module.py + evolve_tool_descriptions.py mirroring the
Phase 1 pattern: all target tool descriptions optimized together in one
router instructions block (cross-tool competition, not independent mutation)
using marker-delimited sections that survive GEPA rewrites. First real run
(read_file/write_file/search_files/terminal, Grok 4.3) hit 100% baseline
accuracy immediately — no learning signal, dataset too easy; needs harder
confusable cases to be a meaningful test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant