Strategy Gene Evolution System

Strategy Gene is based on the GEP paper, encoding experience into compact Gene objects (~230 tokens) instead of document-style Skill packages (~2500 tokens). Genes are implemented at the Hard Constraint layer of the Control Loop, achieving self-optimization through task matching, dynamic injection, and failure-driven evolution.

Gene Structure

Each Gene contains three sections:

[HARD CONSTRAINTS]
- Task-specific constraints and rules
- Conditions that MUST be satisfied

[CONTROL ACTION]
- Recommended actions for this task type
- MUST DO / MUST NOT DO directives

[AVOID]
- Patterns that led to failures
- Auto-extracted from failure feedback

Task Matching

TaskSignalMatcher matches Gene templates via keywords, and matched Genes are injected into the LLM system prompt:

FieldDescription
task_signalsKeywords for task type matching
task_typeTask category identifier
titleHuman-readable gene title

Evolution Mechanism

Genes support automatic and manual evolution:

  1. Failure Detection - 3 consecutive failures trigger evolution conditions
  2. Auto-Extract - Avoid Cues extracted from failure feedback
  3. Version Update - New Avoid Cue written to [AVOID] section, version +1
  4. History Tracking - evolution_history tracks all changes

Avoid Cues Auto-Extraction

The system automatically extracts failure-avoidance hints:

  • Consecutive failure pattern - Adds 'DON'T: Repeat patterns causing N consecutive failures'
  • High failure rate - Adds 'DON'T: Approaches with N% failure rate'
  • Low-reward strategies - Adds 'DON'T: Low-reward strategies (avg N.NN)'

Version Management

Each Gene maintains version history:

{
  "version": 3,
  "evolution_history": [
    {"version": 2, "change": "auto-extract: 2 avoid cues", "at": "2024-01-15T10:30:00"},
    {"version": 3, "change": "manual edit", "at": "2024-01-16T14:20:00"}
  ]
}

Performance Metrics

MetricDescription
usage_countTotal times this gene was used
success_count / failure_countSuccess/failure statistics
success_rateSuccess rate (0.0 - 1.0)
avg_rewardAverage reward from FeedbackEvaluator
consecutive_success / failureConsecutive success/failure streaks

Gene Composer

GeneComposer supports merging multiple Genes in multi-task scenarios, avoiding conflicts while preserving effective constraints from each.

Paper Reference

This implementation references the Strategy Gene paper (arXiv:2604.15097). Thanks to the research team for their contribution.