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

推荐订阅源

大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
小众软件
小众软件
V
V2EX
博客园 - Franky
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
量子位
博客园 - 【当耐特】
雷峰网
雷峰网
WordPress大学
WordPress大学
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Visual Studio Blog
Microsoft Security Blog
Microsoft Security Blog

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
Memory and Context Windows: Best Practices for AI Tools
Liatmoss · 2026-05-16 · via DEV Community

As new tools and features come out, AI tools get more complex giving us more capabilities and ways of working. What also comes along with these updates and changes, is a higher rate of tokens exchanged in both prompts and responses.

From the beginning, we've been told that the more detailed a prompt the more accurate our response from the server is likely to be. With added skills like Grill-Me or Superpowers we are able to refine ideas and create more purposeful prompts but there's also the added cost.

What a lot of people don't realise, is that prompts and responses are only one way that token usage is eaten. What I've seen from a lot of people recently, are context windows that stay open for longer than required, details being pulled from memory long after caching has expired and multiple chats happening within the same context or chat window.

While this may seem like a time saver, and it is, there's a hidden memory cost hiding in every prompt sent in that window. You might think it's a good idea because "the AI remembers" but it reality, the AI is just regurgitating previous information that it's already retrieved.


There are a few "Best Practices" that are important to consider when first looking at context windows and memory:

New chat, new session: This is really important because you don't want to change or adapt what is currently already in your session memory. If you have a question or a new piece of work to do, mostly unrelated to your existing chat, start a new session in the CLI or open a new chat window in the IDE.

This is important for two main reasons; it keeps your sessions clean and easy to find later and it sets a new agent with a new set of memories to recall making the response faster and more cost effective.

Summarise your current session: Summarising your current session and opening a new session to start over means that your agent will be able to retrieve detail from memory faster. It also opens up the context window allowing newer information to be set in memory and easily retrievable

One way I do this is by having my coding agent create a summary document, either in markdown or confluence and use that to set my prompt in the next session.

AI DOES NOT REMEMBER: AI does not have a working memory. Every time you ask something of your AI tool, it retrieves what it thinks is relevant information (also why specific prompts are important). Everything it takes in is stored in the context window to be easily repeated should you need it later. As soon as you ask a new question unrelated to the previous one, everything in that previous memory is deleted and is replaced with new memory for your new question.

If you then want to go back to your first problem, it has to go back and retrieve all of that important information again, removing the previous log from it's memory

Small sessions are good sessions: While this may seem like a lot of work and looks less efficient from the outset, your output is going to be much more efficient. You'll need to bring your agent back on track less, debugging problems in the agent generated code will be faster and the overall chat history remains cleaner.

Utilise your Instructions.md: All coding agents have a version of this file. For GHCP it's Instructions.md for Claude it's Claude.md.

Anything that is repeated across sessions should go into one of these files. This can include specific linting that you want for your repo or specific coding practices that need to be remembered between sessions. Having that information in one of these files means that you don't need to bring it into working memory each session and it's preloaded when you open up either chat or the CLI.

Don't switch models in the same session: This might seem like a good idea to do for code review or to see what outputs differ but as soon as a new model is loaded, the previous memory disappears. While it's important to review code or documentation with multiple models for new perspectives, this should be done in a new chat or context window.


As the models get more powerful and our workload with AI increases, it can be tempting to keep windows and chats open for hours, days or even weeks!

It's important to start working with these kind of practices in mind now, while we are still figuring out the best way to utilise these tools effective before we are too overwhelmed and stuck in our ways.

Think of the AI tools like an online meeting; each new topic is a new meeting where the relevant team members are invited. You don't sit all day or all week in the same call switching between coding projects, repos and tickets with different people constantly jumping in and out.

AI works the same. The clearer and more focused the session, the better the output we are going to receive.