Skip to content

v2.0: Self-Evolving Agents — agents that rewrite their own prompts, tools, and routing rules #732

Closed

Description

@AmitoVrito

Summary

Build a SelfImprovingAgent that uses production traces to autonomously rewrite its own prompts, tool definitions, and routing rules — gated by the existing @eval_case suite and PromptOptimizer.

Motivation

We already ship the building blocks: ContinuousTrainer, FeedbackCollector, A/B testing, AutoRolloutManager, PromptOptimizer, CostQualityRouter. Today they require a human in the loop to interpret signals and apply changes. The next leap is closing that loop: the agent proposes its own config diff, the eval harness validates it, and AutoRolloutManager ships it canary-style.

No competitor in the LangChain ecosystem has a clean, governed self-improvement loop. This becomes the headline feature of v2.0.

Design Sketch

from synapsekit import SelfImprovingAgent, EvalSuite, RolloutPolicy

agent = SelfImprovingAgent(
    base_agent=my_agent,
    eval_suite=EvalSuite.from_decorators(),
    rollout=RolloutPolicy(
        canary_pct=5,
        min_eval_score=0.85,
        rollback_on_regression=True,
        require_human_approval_for=[\"tool_addition\", \"prompt_rewrite\"],
    ),
    improvement_targets=[\"prompt\", \"tool_selection\", \"routing\", \"few_shot_examples\"],
    cadence=\"every_1000_runs\",
)

Loop

  1. Observe — collect last N traces via FeedbackCollector
  2. Diagnose — meta-LLM analyzes failure clusters
  3. Propose — generates candidate diffs (new prompt, new tool, new routing rule)
  4. Validate — PromptOptimizer scores candidates against EvalSuite
  5. Canary — AutoRolloutManager ships to 5% traffic
  6. Promote or rollback — automated based on live KPIs
  7. Audit log — every change is a signed, reversible AgentConfigPatch

Required Components

  • SelfImprovingAgent wrapper class
  • AgentConfigPatch — diff format for prompts/tools/routing
  • MetaAnalyzer — uses ReasoningLLM to cluster failures
  • RolloutPolicy — declarative guardrails
  • Audit trail (signed, replay-able)
  • CLI: synapsekit agent inspect-evolution <agent-id>
  • Eval-blocked default: a patch can NEVER ship without passing the eval suite
  • Integration with PrometheusMetrics (emit agent_evolution_* gauges)

Risks / Open Questions

  • Governance: should tool addition require human approval by default? (proposed: yes)
  • Reward hacking: agent could optimize for eval suite without improving real quality — need adversarial eval cases
  • Cost runaway: meta-LLM analysis on every cycle is expensive — cadence must be tunable
  • Reproducibility: replay-from-patch must be deterministic

Acceptance Criteria

  • End-to-end demo: agent autonomously improves accuracy on a benchmark task over 5 evolution cycles
  • All patches reversible via agent.rollback(patch_id)
  • Full audit log queryable via agent.evolution_history()
  • Docs page + example notebook
  • 100% branch coverage on rollout policy

Related

Activity

  1. added
    enhancement
    v2.0
    research
    agents
    on Jun 25, 2026
  2. added this to the v2.0.0 milestone on Jun 25, 2026
  3. self-assigned this
    on Jun 30, 2026
  4. added
    v2.0.1
    and removed
    v2.0
    on Jul 18, 2026
  5. modified the milestones: v2.0.0, v2.0.1 on Jul 18, 2026
  6. AmitoVrito commented on Aug 1, 2026

    @AmitoVrito
    CollaboratorAuthor

    Status: implementation complete — acceptance-criteria polish pending

    Shipped (in src/synapsekit/agents/self_improving.py + training/): SelfImprovingAgent (eval-blocked, grounded gate), AgentConfigPatch (signed + reversible), MetaAnalyzer, RolloutPolicy, rollback(patch_id), evolution_history(), _validate_patch (eval gate), CLI synapsekit agent inspect-evolution, Prometheus agent_evolution_* gauges, 14 tests, examples/self_improving_agent.py.

    Pending to close this issue (acceptance criteria):

    • End-to-end benchmark: agent autonomously improves accuracy on a benchmark task over 5 evolution cycles — via benchmarks/self_evolving_bench.py + benchmarks/test_self_evolving_bench.py gate + a self-evolving-gate CI job (same pattern as agent-swarm-market-gate).
    • Docs page + example notebook (script exists; docs-site page does not).
    • 100% branch coverage on the rollout policy.
  7. Satiankit96 commented on Aug 1, 2026

    @Satiankit96
    Contributor

    W0Ankit_00

  8. removed their assignment
    on Aug 3, 2026
  9. AmitoVrito commented on Aug 4, 2026

    @AmitoVrito
    CollaboratorAuthor

    Closed in v2.0.1. All acceptance criteria met:

    • ✅ End-to-end demo improving accuracy over 5 cycles — benchmarks/self_evolving_bench.py (37.5% → 100%), CI-gated by self-evolving-gate
    • ✅ All patches reversible via agent.rollback(patch_id)
    • ✅ Full audit log via agent.evolution_history() + synapsekit agent inspect-evolution
    • ✅ Docs page (docs/agents/self-improving.md) + example notebook (examples/self_evolving_agent.ipynb, offline & CI-tested)
    • ✅ 100% branch coverage on RolloutPolicy (24/24 branches)

    Bonus: the evolution loop now streams to the SynapseKit Live dashboard (agent.evolve / agent.rollback events).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agentsenhancementresearchv2.0.1

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions