DEV Community

golflover
golflover

Posted on

The Four-Gear Self-Evolution Loop: How a MeshCtx Agent Grades Its Own Homework

Most agent "memory" features are note-taking with extra steps: save a summary, paste it into the next prompt, call it learning. We wanted something stricter for MeshCtx, our open-core (AGPLv3) agent platform — so we built a full self-evolution loop where insights have to earn their place, and can lose it. Here is the architecture.

The problem with static prompts

A system prompt is frozen at deploy time. Whatever the agent learns in production dies in the transcript unless a human hand-moves it into a config file somewhere. The loop we shipped removes the human from that particular loop — with an audit trail, because an agent that rewrites its own rules is a liability unless you can verify what it learned.

Gear 1: record

Every conversation result and every code-run result flows into an experience layer. Entries are append-only and integrity-checked with a hash chain, so history cannot be quietly rewritten. You can trace exactly which experience produced which insight, and when it entered the prompt.

Gear 2: reflect

The agent does not wait for a human to review its notes. Once a batch of records accumulates, reflection triggers automatically and distills them into insights. A periodic guardian cycle keeps reflection running in the background between sessions, with a throttle so it cannot busy-loop.

Gear 3: inject

The strongest insights are written into the system prompt itself — top-ranked only. If there are no insights worth injecting, behavior does not change at all. No placebo mode.

Gear 4: reinforce

This is the part most setups skip. When a conversation ends, the real outcome flows back with success/failure attribution. Insights that correlate with good results gain retention strength; insights that do not, decay. It is selection pressure applied to the agent's own rules — closer to how training works than to how "memory" usually works.

The whole cycle was verified end to end in the latest build: records accumulate, reflection triggers on its own, distilled insights land in the system prompt, and later conversations reinforce or weaken them based on what actually happened.

What else landed alongside

The same build wave brought a model health badge surface (24h liveness success rates per provider, aggregated from the experience layer), a side-by-side multi-model comparison chat card with latency and scoring, and clipboard-based API key import with automatic provider prefix detection. Plus i18n maintenance across the 11-language UI, including RTL behavior coverage for Hebrew and Arabic.

Try it

MeshCtx is open core under AGPLv3, with downloads for Windows, macOS (Apple Silicon / Intel) and portable Linux on the releases page. The full changelog documents every gear of the loop with the commits behind it.

If your agent keeps a diary, that is cute. If it grades its own diary and demotes the wrong lessons, that is a loop.

Top comments (0)