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

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Webroot Blog
Webroot Blog
U
Unit 42
A
About on SuperTechFans
宝玉的分享
宝玉的分享
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
Intezer
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
V2EX
L
LangChain Blog
AI
AI
G
GRAHAM CLULEY
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
Docker
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
I
InfoQ
Y
Y Combinator Blog
C
Comments on: Blog
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
Vercel News
Vercel News
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿

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 Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Teach Your Agent to Forget (On Purpose)
Athreya aka Maneshwar · 2026-06-14 · via DEV Community

Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback.

Part 2 of a series on context engineering. Part 1 was the map of the whole thing. This is one of the harder pieces of territory — the discipline of throwing things away without throwing away the plot.

Here's a thing that happens to everyone who builds a long-running agent.

At turn 10, it's brilliant.

Sharp, fast, remembers exactly what you asked, threads the needle on the tricky bug.

You feel like a wizard.

At turn 80, it's a different creature.

It re-suggests a fix you already rejected.

It "forgets" the file it edited twenty turns ago.

It contradicts a decision you both made at the start.

The same model, the same prompt, the same task and it's somehow gotten dumber as it learned more.

That's not a bug in the model.

That's the desk filling up.

In Part 1 I made the case that the context window is RAM, not a hard drive, working memory with a hard edge.

Everything the model can reason about has to fit on the desk.

The long conversation is what happens when you keep piling paper on that desk and never clear any of it.

Eventually the important sheet is buried under four hundred lines of tool output, and the model is doing your taxes at a party while standing in a paper avalanche.

Compaction is how you clear the desk without sweeping the important sheet into the trash.

Of the four moves from Part 1 — write, retrieve, compact, isolate this is the one people get most confidently wrong.

Because on the surface it looks trivial: "just summarize the conversation." And then they ship a summarizer, and their agent starts quietly losing its mind.

Let's do it properly.

What compaction actually is (and what it isn't)

Compaction is lossy compression for meaning.

You take a long, sprawling history and replace it with a shorter representation that preserves what matters for the next step and discards what doesn't.

The "lossy" part is the whole game.

If it were lossless, it wouldn't help, you'd just have the same tokens in a different font.

Compaction works precisely because it throws information away.

The skill is in what you throw away.

Two things it is not, and conflating them will hurt you:

Clearing is amnesia. /clear wipes the history and starts fresh, useful when you're switching tasks, catastrophic mid-task.
Trimming is mechanical. Dropping the oldest N messages by a hard rule, no model involved. Cheap, fast, dumb. It doesn't know that the oldest message is the one decision the whole task hinges on.

Compaction sits between them: smarter than trimming, less destructive than clearing.

It uses a model to decide what's worth keeping and rewrites the rest into something dense.

Why "just summarize it" goes wrong

Naive compaction fails in ways that are worth naming, because once you can name them you can design against them.

Drew Breunig has a clean taxonomy of how long context rots, and every one of these can be introduced by a sloppy compaction:

  • Poisoning: a hallucination makes it into the summary, and now it's load-bearing. The model treats its own earlier mistake as established fact and builds on it. Compaction can launder a guess into a "decision."
  • Distraction: the summary keeps so much that it just recreates the original bloat. Congratulations, you compacted a 50K conversation down to 48K.
  • Confusion: superfluous detail survives the cut and pulls the model toward irrelevant work.
  • Clash: the summary and the live messages disagree, and the model has to referee a fight between two versions of reality.

And then there's the failure mode unique to repeated compaction, which is the scary one: cumulative erosion.

Each compaction is lossy.

Compact a compaction and you lose a little more.

Do it five times across a marathon session and you've played telephone with your own task, the agent is now working from a summary of a summary of a summary, and the specific constraint you set at turn 3 ("never touch the auth module") is three generations of paraphrase away from the original.

This is the real reason agents "go off the rails" after an auto-compact fires mid-task: the boundary isn't just a token reduction, it's a behavioral discontinuity.

The agent on the other side is, in a real sense, a slightly different agent working from slightly worse notes.

You can't eliminate this.

You can only be deliberate about slowing it down.

The anatomy of a good compaction

So what survives the cut? Here's the heuristic that holds up across basically every serious implementation: keep the decisions and the state, discard the process that produced them.

Remember the example from Part 1, the agent that searched the database and found the user's table is documents_v2? I told you to hold that thought. Here's why it comes back.

A good compaction keeps: "The user's table is documents_v2."

A good compaction discards: the 400 lines of JSON the model waded through to figure that out.

That single line is the entire philosophy in miniature.

The fact is durable and tiny.

The evidence for the fact is enormous and now useless, you already extracted the value from it.

Keeping the JSON is paying rent forever on information you've already cashed out.

Generalize it and you get the checklist that every good handoff summary converges on:

Keep Drop
What was decided, and the why behind it The deliberation that led to the decision
Current state of files / system Intermediate states already overwritten
Explicit user constraints and preferences Pleasantries, acknowledgements, retries
What's in progress right now Completed-and-verified subtasks (one line each)
Concrete next steps Raw tool output you've already digested
Critical references (table names, IDs, paths) The search that found them

The constraints line deserves emphasis: user constraints are the most expensive thing to lose and the easiest thing to drop.

"Decided to use Postgres" looks like a fact worth keeping.

"User said never to touch the auth module" looks like old conversational noise.

The second one is the one that, when lost, makes your agent confidently do the one thing it was told not to.

Pin constraints.

They should survive every compaction unchanged, never paraphrased.

How the real tools do it

Two production coding agents are worth contrasting, because they agree on the problem and disagree on the manners.

Claude Code leans on automation.

There's a manual /compact command, but the headline behavior is auto-compaction firing at roughly 95% of the context window, it summarizes the full trajectory and starts fresh with that summary as the seed.

You can steer it (/compact "focus on the open TODOs"), and it's distinct from /clear.

The community consensus, tellingly, is that 95% is too late: by the time you're that full, the conversation's already degrading, and people compact manually well before the trigger.

OpenAI's Codex CLI is more "handoff"-flavored. Its prompt frames compaction as a checkpoint producing a summary for "another LLM that will resume the task," and tells that next model to build on the work rather than redo it.

It triggers on a token threshold, keeps the most recent user messages verbatim alongside the summary, and has retry-with-backoff for when the compaction call itself fails. (Compaction is an LLM call. LLM calls fail. Plan for it.)

If you're building your own

Synthesizing into the decisions you'll actually have to make:

Trigger earlier than you think. 95% is the cautionary tale, not the recommendation.

Around 85–90% lets you compact while the context is still good enough to summarize well.

Prune before you summarize. Run a cheap mechanical pass that drops stale tool output first.

Summarization is your expensive, lossy tool, don't spend it on 400 lines of JSON you can just delete.

Keep recent turns verbatim. Compact the distant past; preserve the present.

The model needs the live, un-paraphrased thread of what's happening right now.

Pin constraints, and tell the user it happened. Carry user constraints through every compaction as exact text, they're the thing that does the most damage when lost.

And a silent compaction that changes behavior mid-task just feels like the agent randomly got worse; one line ("compacted history to free up context") turns a mystery into a tradeoff.

And a starting prompt, since you'll need one:

Create a handoff summary so this coding session can continue in a fresh context.
The summary will be the ONLY history available, so preserve:

1. Completed work — what's done and verified (one line each)
2. Current state — files modified and their status
3. In progress — what is being worked on right now
4. Next steps — concrete actions to take
5. Constraints — user preferences and requirements, quoted exactly
6. Critical references — table names, IDs, file paths, key decisions and the why

Be dense. Drop deliberation, raw tool output, and anything already superseded.
Do not invent or assume anything not present in the conversation.

That last line — do not invent — is your cheapest defense against poisoning.

The summarizer's job is compression, not creativity.

The moment it starts filling gaps, it's manufacturing the hallucination that turn 80 will treat as gospel.

The uncomfortable part

Compaction forces you to admit something the rest of the stack lets you avoid: you cannot keep everything, so you have to decide what your agent is allowed to forget.

External memory and retrieval let you dodge that, stash it, pull it back later.

But inside a single long-running task, on a finite desk, there's no dodge left.

Something has to go, and compaction is choosing what survives on purpose, instead of letting the context window choose for you by quietly shoving your most important constraint off the edge of attention.

The best compaction, like the best engineering, is mostly subtraction.

It's keeping documents_v2 and burning the JSON, one line of constraint outliving a thousand lines of chatter.

The mantra from Part 1 gets sharper here: the best token is the one you didn't have to send.

Compaction is how you find out which tokens those were, and have the nerve to delete them.

Disclaimer: This article was written by me; AI was used to fix grammar and improve readability.

AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs — without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

⭐ Star it on GitHub:


AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

See It In Action

See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements

git-lrc-intro-60s.mp4

Why

  • 🤖 AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
  • 🔍 Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.