惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
Y
Y Combinator Blog
月光博客
月光博客
IT之家
IT之家
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - Franky
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
V
Visual Studio Blog
小众软件
小众软件
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Why your AI agent needs an undo button (and how to build ...
AgentRein · 2026-05-14 · via DEV Community

`AI agents are no longer just generating text. They're sending emails, pushing code, updating CRM records, and modifying databases.

And when they go wrong, they really go wrong.

I've seen this pattern repeatedly: an agent works perfectly in testing, gets deployed, and then sends 200 emails to the wrong list. Or deletes the wrong GitHub issues. Or overwrites 3 months of CRM data.

The model didn't fail. The prompt was fine. There was just no safety net.

The problem isn't the agent. It's the execution layer.

Most teams handle this with logging. They add Langfuse or Helicone, watch the traces, and hope they catch mistakes before they happen.

But logging tells you what went wrong after it happened. What you actually need is the ability to undo it.

What reversible execution looks like

The core idea is simple: before any action executes, you log it. After it executes, you store enough information to reverse it. If something goes wrong, you unwind in LIFO order.

For every connector, you need a compensation handler, a function that defines what "undo" means for that specific action:

`typescript
// Email sent: can't unsend, but can send correction
compensate: async (action) => {
await sendCorrection(action.payload.to, action.payload.subject)
await flagThread(action.payload.threadId)
}

// CRM record updated: revert to snapshot
compensate: async (action) => {
await crm.records.update(action.payload.recordId, action.snapshot.before)
}

// GitHub issue created: close it
compensate: async (action) => {
await octokit.issues.update({
issue_number: action.result.number,
state: 'closed'
})
}
`

Compensation isn't symmetric. "Undo send email" is not the same as "delete sent email." The action already had consequences. So each handler has to be action-aware, not generic.

Approval gates for high-risk actions

Not every action needs rollback. Some need prevention.

The pattern that works: define a risk threshold per action type. Actions above the threshold pause and wait for human approval before executing.

typescript
const session = await agentrein.newSession({
agentId: 'email-agent',
intent: 'Send follow-up emails to leads from last week',
approvalRules: [
{ action: 'gmail.send', requireApproval: true },
{ action: 'gmail.draft', requireApproval: false }
]
})

The audit trail problem

Even with rollback and approval gates, you need to know why the agent took each action, not just what it did.

Most logging tools capture the API call. What you actually need is the intent at the time of execution: what was the agent trying to accomplish, and did this action match that goal?

What we built

We built AgentRein to solve exactly this, a drop-in SDK that wraps your existing tools and adds rollback, approval gates, and audit logs.

`typescript
import { AgentRein } from 'agentrein'
import { Octokit } from '@octokit/rest'

const agentrein = new AgentRein({ apiKey: 'YOUR_API_KEY' })
const octokit = new Octokit({ auth: 'GITHUB_TOKEN' })

const session = await agentrein.newSession({
agentId: 'onboarding-agent',
intent: 'Create GitHub issue and notify Slack'
})

const agentOctokit = agentrein.wrap(octokit, session, { connector: 'github' })

const issue = await agentOctokit.issues.create({
owner: 'my-org',
repo: 'my-repo',
title: 'Onboarding task'
})

await agentrein.completeSession(session)
`

Pre-built compensation handlers for GitHub, Stripe, Slack, Gmail, Notion, HubSpot. Free tier available.

If you're running agents in production that touch real systems, I'd love your feedback: agentrein.com`