DevelopmentJuly 6, 2026· via DEV Community

AI agents forget context—here’s how to keep them honest

AI agents forget context—here’s how to keep them honest

Image : DEV Community

Last week, an AI agent tried to solve a payment failure by repeating a mistake the team had already fixed—adding card data to their own database. The error? It had no memory of the previous attempt, which had been reverted after just two days to avoid PCI compliance issues. That’s the hidden cost of using AI agents in development: the code sticks around, but the reasoning vanishes when the session ends.

The context gap in AI-driven development

Agents work quickly, but their short-term memory is limited to the current session. When a developer reverts a change or closes the tool, the rationale behind it disappears—along with any documentation. In this case, the team had moved card storage to Stripe’s managed system to stay out of PCI-DSS scope, yet the agent proposed the same flawed solution months later. The problem isn’t the agent’s logic; it’s the lack of persistent context.

A tool to capture AI reasoning before it’s lost

To prevent this, developer Mason DeLan created Selvedge, a local MCP server that records an agent’s reasoning in real time. When an agent proposes a change, Selvedge prompts it to document why—storing the explanation directly alongside the code. The next time the agent encounters the same issue, it can check prior attempts and avoid repeating them.

Selvedge works by reading a simple four-line block in a project’s CLAUDE.md file, which tells the agent to consult its history before making changes. The tool then surfaces past decisions, their outcomes, and the reasoning behind them—without relying on external models or telemetry. All data stays in a local SQLite file, ensuring privacy and speed.

Why this matters beyond one engineering team

This isn’t just about avoiding PCI compliance headaches. For teams using AI agents for code reviews, infrastructure changes, or even documentation updates, lost context leads to wasted time and duplicated effort. Selvedge’s approach—capturing reasoning in the moment—offers a lightweight way to preserve institutional knowledge, even as developers and models come and go.

The project is open source, and its creator invites feedback from anyone who runs into the same frustration: forgetting why a change was made long after the session is closed.


Source: DEV Community. AI-assisted editorial synthesis — TechnoExpress.

Read the original source on DEV Community →

← Back to home