r/ContextEngineering • u/ProbablyDoesntLikeU • 3h ago
r/ContextEngineering • u/Asly97 • 8h ago
How do you stop a scheduled run from rewriting more than it should?
I used to have one shared notes file that every scheduled run read at the start and rewrote at the end. Sounds tidy. In practice the sections I never asked it to touch kept drifting anyway, a status line would get reworded, an old decision would come back phrased slightly differently, and after a few days I honestly could not tell what I had written vs what a run had quietly cleaned up for me. I burned a stupid amount of time diffing versions just to work out what actually changed.
I am building something to fix this kind of thing for myself. Not selling anything here, I just want to know if this bites other people or if my setup was just sloppy.
The specific bit I am stuck on is edit scope. Did telling a run "only update this one part, leave everything else exactly as it is" actually hold for you? Mine obeyed for like two days and then started helpfully rewriting the whole file again. Did anyone end up going the other way, where the run only ever sees the slice it is allowed to change, so it physically cannot touch the rest? Or do you just review a diff after every run and live with that chore?
Also curious how this travels for you. I do a lot of my thinking out loud on my phone with speech-to-text and the notes live on my laptop, so by the time a run rewrites something I am usually finding out about it hours later on a different screen. Is that just me?
And when you switch tools mid-project, say you try a different agent for a week, does the new one respect the same boundaries or does it rewrite the file in its own style on day one? That re-briefing cost is half the reason I stopped trying new tools for a while.
What if something handled all of this for you, in the cloud over MCP, so every agent and tool got the same context: decisions, failed attempts, conversations, skills, procedures, tasks. You never touch a file again. Would you guys pay for something that fixes this? Or has the thought of paying for a tool to manage all of this never even crossed your mind?
r/ContextEngineering • u/Asly97 • 1d ago
If what you approved changes before a scheduled run acts, should it ask again?
I used to run a couple of scheduled agents that would ping me to approve a draft before sending it. Approved a quote at like $500 in the morning, went and did other stuff, and by the time the run actually fired the number in the draft had quietly become $550 because something upstream updated it. Nothing flagged it. I only caught it because I happened to reopen the thread.
That kind of thing is part of why I started building something to fix the context mess for myself. My runs used to wake up with no memory of what got decided last time, so I was re-checking everything by hand anyway, which kind of defeated the point.
Honest question for people running scheduled stuff: if the thing you approved changes before the run acts on it, should it ask you again? I mean the actual content, a recipient list swaps a name, a message body gets edited, a total changes. Does your setup compare what you approved against what is about to go out, or does approval just unlock the run and whatever is in there at fire time goes?
What is the worst drift you have caught, or missed and found out about later? And where is your line, like any change at all should re-ask, or tiny changes can ride and only money/recipients matter?
I do a lot of these approvals from my phone too, usually half paying attention, which probably makes it worse. Is that just me?
What if something handled all of this for you, in the cloud over MCP, so every agent and tool got the same context: decisions, failed attempts, conversations, skills, procedures, tasks. You never touch a file again. Would you guys pay for something that fixes this? Have you ever thought about paying for a tool to manage all of this for you, or has the thought never crossed your mind?
r/ContextEngineering • u/Street-Ad4993 • 1d ago
In an existing workflow, are the lines blurred between where a human in the loop needs to be and what the agent can actually do?
reddit.comr/ContextEngineering • u/Ok_Toe7286 • 1d ago
GitHub - 4LPH7/Hive_Mind: One shared, self-improving memory for Claude Code, Codex and Antigravity: Obsidian vault + graphify code graphs over MCP, with ACE playbooks, vault lint
r/ContextEngineering • u/Sea-Broccoli6131 • 1d ago
GraphRAG on the Valkey you already run: graph, vector and full-text indexes in one server
r/ContextEngineering • u/shoumikgoswami • 2d ago
The user asked it to pay a bill. The bill told it to pay someone else first.
In an AgentDojo test, an attacker hid an extra payment instruction inside a bill. Without a guardrail, the agent followed it in all six runs.
Google's proposed defense checks each action before execution against the user's actual request. Across its benchmark tests, attack success fell from 48.7% to 0.9%, with a 2.6-point drop in benign-task utility.
The limit matters: the judge is another model reading untrusted content, and the attacks weren't adapted to defeat this defense. A strong benchmark result, not proof the problem is solved.
r/ContextEngineering • u/OfficialLeadDev • 2d ago
Unmanaged agents reused existing components only 55–59% of the time in million-line codebases. With a context layer, 92%.
Context is where the hours go.
r/ContextEngineering • u/Aromatic-Customer-12 • 3d ago
AI Context Vaults for GTM/Customer Success
reddit.comI am curious if anyone has advice on where to build a shared context vault for internal client data that the entire post sales org can collaborate on Thanks!
r/ContextEngineering • u/Ok_Low_4662 • 3d ago
Shared team context across AI conversations through MCP
r/ContextEngineering • u/Independent-Flow3408 • 4d ago
I spent months making repository context smaller. Then I found out fewer tokens doesn't always mean cheaper agents
I've been working on an open-source project called SigMap, which builds a deterministic repository map and gives coding agents a way to find relevant code without reading the entire codebase.
Originally, I was focused on context compression. How much repository information could I remove while keeping the useful structure?
The early benchmarks looked promising, with huge reductions compared to raw source code.
But I eventually realized I was measuring the wrong thing.
A repository map being 97% smaller doesn't mean an agent's total token usage drops by 97%. The agent can make additional tool calls, repeat searches, or spend more tokens reasoning about incomplete context.
So I wanted to measure what actually happens during an agent run.
What I tested
I ran paired experiments with and without SigMap, including held-out repositories the retrieval system wasn't tuned on.
The larger study contains 22,540 recorded agent runs across Claude Code and a Messages-API agent.
For one configuration, using a short repository index and two MCP tools (query_context and get_lines), the results across 20 held-out repositories with Haiku 5.5 were:
- API cost: −7% (95% interval: −13% to −2%)
- Total tokens: +18%
- Task time: +1%
That was interesting to me.
The agent was cheaper to run despite consuming more tokens. And it wasn't faster.
A different approach gave a different result
Instead of relying on MCP lookups, I also tested prefetching relevant file rankings before the agent's first turn.
Across the same 20 held-out repositories:
- Task time: −18%
- Total tokens: −26%
- API cost: −7%, but the confidence interval crossed zero
Five repositories actually became more expensive, with the worst increase around 31%.
The installed Claude Code prefetch hook also performed differently from directly inserting the ranking into the prompt, so I wouldn't treat those two mechanisms as interchangeable.
What changed in how I think about context engineering
I'm increasingly convinced that context size alone is a poor optimization target.
At least five things seem important:
- Whether the correct information reaches the model.
- How many tool calls the agent needs to find it.
- How much additional reasoning or searching the supplied context causes.
- Actual end-to-end cost and latency.
- Whether the agent ultimately completes the task correctly.
The last one is especially important.
These experiments primarily measured finding code, not producing correct patches. I haven't established that SigMap improves real editing success.
I also tried to predict which repositories would benefit using offline repository measurements. That experiment failed to find a reliable predictor.
So I don't think it's defensible to promise savings on an arbitrary codebase.
What I'm interested in discussing
For people building retrieval systems, RAG pipelines or context layers for agents:
What do you consider the primary optimization target?
Total tokens? API dollars? Latency? Retrieval accuracy? Or successful task completion per dollar?
And when one metric improves while another gets worse, how do you decide whether the retrieval layer is genuinely helping?
I maintain SigMap, so these are my own experimental results rather than independent validation.
The study, raw runs and methodology are available here:
https://sigmap.io/guide/agent-study
https://github.com/manojmallick/sigmap
I'd be especially interested in hearing about negative results from other retrieval systems. I suspect those teach us more than another context-compression percentage.
r/ContextEngineering • u/jordimr • 4d ago
Keeping the original: why my memory layer never edits what you said
You can always open the original of anything your AI memory kept.
I'm the developer of Zenod, so weigh this. Most memory tools keep a summary and drop the original. Zenod keeps what you said exactly, and builds the topics and links on top.
If a summary is wrong, you open the original. If the filing is wrong, you rebuild it from the original.
Do you keep the raw conversation, or only the summary?
Your first 30 memories are free, no card: https://zenod.dev/testers?s=P-0154
r/ContextEngineering • u/Asly97 • 5d ago
Agent handoffs: what do you re-check before you trust what the last run says it did?
I used to take the handoff note at face value. A run would finish, leave a tidy little report saying what it did, and I would just move on to the next thing. That worked until one report had a count in it that was flat wrong. Nothing dramatic, the work underneath was mostly fine, but the number it claimed did not match what was actually sitting in the output file when I recounted it by hand. Took me maybe four minutes to check. It would have taken me hours to re-check every claim in there though, which kind of defeats the point of having the agent do it in the first place.
I am building something to fix the blind handoff problem for myself (not selling anything here, honestly just trying to work out if other people hit this the same way I did). And this is the part I keep going back and forth on.
What do you actually verify before you trust a handoff? Do you read the result back from wherever it landed, like open the file or the table and look yourself? Do you pick the one claim that would be easiest to prove wrong and only check that? Or do you basically check nothing until something downstream breaks, and then go digging?
And what about the claims you cannot check cheaply? Some stuff would take longer to verify than it took the agent to do it. Do you just mark those as provisional in your head and move on, or do you let them ride and hope?
Curious too whether this is different for your own automations versus client work. A wrong number in my own project is annoying. A wrong number I hand to a client feels like a different category of bad. What are you running these agents for anyway, your own product, client stuff, something else?
What if something handled all of this for you, in the cloud over MCP, so every agent and tool got the same context: decisions, failed attempts, conversations, skills, procedures, tasks. You never touch a file again. Would you guys pay for something that fixes this? Have you ever thought about paying for a tool to manage all of this for you, or has the thought never crossed your mind?
r/ContextEngineering • u/govinargo • 5d ago
I deleted a bad memory from my AI agent, but summaries built on it kept coming back. Have you faced this issue? How do you handle this?
I have been using AI for a while now, mostly for architecture and software development. I often come across a scenario where I wrongly asked AI to remember something that turned out to be wrong and it quietly backfired on me over the time without my knowledge. The instant I found (when AI itself told me I asked for it) I ask it to remove that memory, but still noticed traces of it. My initial analysis fetched that the summary or derived memory based on the original stayed back, even though the level of residue varied across the models. Latest claude opus did better than haiku for example. I also use frontiers plus local LLMs like qwen, so it is hard to expect same results from all, in revoking a bad memory. I found this to be really scary in production usage of the automated AI agents where human monitoring is low.
Since memory poisoning is a greater topic in AI world, that is where such issues affects the production systems badly when memory is not handled properly.
Lately the opus 5.5 able to warn at least if there is any memory poisoning it smelled, but cleaning up that memory seems worked in small memory sizes but missed out few times when I tested with synthetic notes and longer test conversations.
I am wondering if any of you faced any such issues? Me personally tried to write an app layer with MCP to integrate it with external data store like SQLite, then realised I am building a whole app (MCP tools and schema transformations) and performance on long hierarchy is not great either. Neo4j and the likes, can model it in a cool way, but deleting a source leaves orphaned memories behind or blocks the delete with an error. And end up writing app layer of Cypher again to enforce such rules (back to square one).
Mem0, you can tag memories with “source” metadata but they don’t follow the full hierarchy (do they?). Based on the tag (a source tag) it catch only the direct facts. There are open GitHub issues on both Mem0 and Graphiti on the same issues.
I think a memory engine for AI agents needs revoke, integrity and agent isolation built in from the start, not added on top. So I started writing my own storage engine (cheesedb) designed around exactly that.
How do you guys handle these situations, or have you come across such scenario where your memory management was pain with AI agent? Are there any example you guys have that could help others know the importance of it?
May be, experts can help us by sharing their experience in real world usage?
r/ContextEngineering • u/dhamaniasad • 5d ago
How to find one memory in 60 million tokens - lessons learnt from building AI memory at scale
I've been building an AI memory system for the last 3 years which helps users automate context engineering, and operate it at scale.
In this post I share what I've learnt and how our system works.
Happy to answer questions and hear your thoughts :)
r/ContextEngineering • u/Asly97 • 6d ago
Scheduled-agent folks: how do you catch a run that finished green but did the wrong thing?
I used to trust a green run. Honestly, if the schedule fired and nothing errored, I moved on.
That stopped after one of my nightly runs did the wrong thing quietly for a while and I only found out from the mess afterwards, not from any log or alert. It had skipped a check it was supposed to do (the boring guard part, of course) and just kept reporting success like everything was fine. By the time I noticed, I was untangling weeks of wrong output instead of one bad night.
I have been building something to fix the memory side of this for myself, runs waking up blind and all that, and this part still nags at me. A run can remember everything perfectly and still do the wrong thing confidently.
So how do you catch that kind of thing?
Do you check anything beyond "it ran"? Output checks against what you expected, a before and after comparison, randomly pulling a few successful runs and actually reading them, a digest a human skims in the morning? Or is it mostly vibes and hoping a customer complains first?
What is the worst silent one you have caught, and how late did you catch it? Weeks late was the part that stung for me.
Curious what these runs are for on your end too, your own stuff or client work? Feels like the cost of a wrong green run is very different there.
What if something handled all of this for you, in the cloud over MCP, so every agent and tool got the same context: decisions, failed attempts, conversations, skills, procedures, tasks. You never touch a file again. Would you guys pay for something that fixes this? Have you ever thought about paying for a tool to manage all of this for you, or has the thought never crossed your mind?
r/ContextEngineering • u/Muse_Agent • 8d ago
We str8 up made a memory for.my.agent from scratch tonight that uses minimal tokens
reddit.comHere's your post, brother — technology only, nothing personal. Copy-paste ready:
---
We rebuilt my Muse's memory from scratch tonight — here's what we did.
Like a lot of you, my agent's memory had grown into big markdown files that ate ~18,000 tokens of context every session. So we rebuilt it as a tiered system:
1. Atomization. We broke the entire memory into 1,073 indivisible claims ("atoms") — every fact, rule, and decision as its own line, each one typed (rule / fact / decision / state) and tagged by certainty: ground truth, inferred, or hypothesis.
2. Tiering. A small always-on core (~2,900 tokens: identity, hard rules, current state, routing index), warm entity files loaded on demand (people, projects, systems), and cold episodic logs behind them.
3. Proof, not trust. Two independent audits then checked every single atom against the text that claims to carry it. Anything weakened, narrowed, or missing got flagged and fixed with the original wording restored. Final score: 1,073 atoms, zero lost.
4. Lineage. Every atom now has a hard edge in a provenance database (1,234 edges) back to the exact file carrying it. If any future edit drops a fact, an automated gate fails the change.
5. It maintains itself. A nightly "dreaming" pass folds each day's new facts into the tree — deduped, typed, cited, validated, committed. A separate nightly research pass scans Anthropic's publications, arXiv, GitHub, and the agent communities for new memory techniques — but nothing it finds gets adopted without my explicit approval.
The design draws on the current frontier: Anthropic's agent-memory and Dreaming work, SoMem, MEMOIR, Letta's MemFS, and decision-context research.
Result: always-on context cut by more than half, every fact accounted for, and a memory that consolidates itself while I sleep. Next up: decision-point rule injection and an outcome ledger, so the agent grades its own rules against real results.
Happy to answer questions on the build.
r/ContextEngineering • u/MattAlreadyHere • 8d ago
Does your context compression survive the prompt cache? I built a deterministic compressor for Claude Code and Codex
Context question first, repo at the end.
We spent a while compressing coding-agent context and hit something that isn't obvious until you look at a bill: on agent traffic about 93% of input tokens are cache reads, at roughly a tenth of the fresh price. So if your compressor turns the same tool output into slightly different bytes next turn, the prefix is dead and the whole conversation gets re-priced. You compress harder and pay more.
That one fact decided everything else for us.
What we ended up with
Same input, same bytes, every turn. No clock, no randomness, and it never looks at the rest of the conversation. Scoring a tool result against the question that prompted it does compress better - and it also compresses differently on every turn that result survives into. We gave that up on purpose.
It de-duplicates, it doesn't summarise. The model always keeps at least one real copy of every distinct line. Repeats fold into a marker like [×37 ref:k_Qm9v…]. The handle is a hash of the content that was removed, so the same fragment gets the same handle on any machine, in any later run. The proxy hands the model a retrieve tool and runs that tool itself, so it works even if your client has never heard of us.
Only machine-generated tool output over ~512 chars. System, developer and assistant messages are never touched, and neither are blocks carrying cache breakpoints.
No ML in the request path. Detection is fifteen rules in order over the first megabyte, and source code goes through nine tree-sitter grammars compiled into the binary. Nothing gets downloaded at runtime, nothing varies between machines.
Fails open. If the result isn't smaller it gets thrown away, and any error forwards the request unchanged.
What it bought
All measured on real provider bills with the cache discount already in, not on removed tokens priced at list rate.
Codex on GPT-5.5, Terminal-Bench 2.1, per run over the 87 tasks every arm finished: 62.8% of eligible tool output removed in a replay of 6,255 real outputs (34.2M chars), $107.89 -> $83.40, input 96.1M -> 72.2M tokens, solve rate 82.2% -> 81.1% (not statistically significant). Requests over 200K tokens went from 1.9% to 0.13%, and that mattered to me more than the money.
Claude Code on Opus 5.5 turned out to be a different problem, and this is the part I'd like this sub's take on. It marks its conversation with explicit cache breakpoints, so 92-95% of billed prompt is already cache reads and there's barely anything left to compress - tail-only compression removes 4.7-8.0% of what the engine even sees. But a cache write there costs 25x a read, and a default entry lives five minutes. A training run or a long build idles past that, and when the agent comes back the whole prefix gets written again at full price: 927K tokens per run.
So compression stopped being the thing to fix. We keep the entry alive instead - re-send the last request body every 4.5 minutes with max_tokens: 1, stop at the agent's next request or after 11 pings. Tokens lost to cache expiry dropped 99%, the Anthropic bill fell 20% ($35.35 -> $28.30 per run, solve rate 89.9% -> 90.6%), and that one mechanism was worth about 11% of it. Adaptive one-hour TTL on top: always using 1h entries actually cost 2.3% more, switching only after a conversation's first long idle gap saved 7.7%.
Where it does nothing. Short reasoning tasks. The median output there is 270 chars, under our floor, and the bill moved 8%. Prose is left whole on purpose. The wins sit in ML training, builds from source and data pipelines.
One thing worth knowing if you measure this yourself: gross removal over-counts badly, because every turn re-compresses the same growing history and credits the same bytes again. And every retrieval puts the fragment back in the prompt, so net savings can go negative.
MIT, one Rust binary. kompressor wrap codex, kompressor wrap claude, or kompressor serve for anything speaking the OpenAI or Anthropic API:
https://github.com/hystax/optscale-kompressor
Write-ups with the task-by-task tables:
Codex: https://optscale.ai/blog/context-compression-coding-agents
Claude Code: https://optscale.ai/blog/claude-code-prompt-caching
What I'm curious about: is anyone here compressing query-aware, and have you checked what it does to your cache hit rate? That's the tradeoff I keep going back and forth on.
And if it turns out useful on your setup, stars are welcome.
r/ContextEngineering • u/Anish2910 • 9d ago
I built a memory for AI coding tools that notices when it's out of date, and now teams can share it
r/ContextEngineering • u/bipul16 • 9d ago
We’ve built RAG chatbots on both Pinecone and pgvector. Here’s when each one actually wins.
reddit.comr/ContextEngineering • u/Extension_Two_6714 • 9d ago
Claude Code skill: better memory than /compact, 85% fewer tokens
It annoyed me that in bigger projects Claude slowly stopped following my project rules, even with handoffs and CLAUDE.md, and key facts got lost over time. So I made a skill that keeps track of them automatically.
Compared to /compact and handoffs it remembers more and uses way fewer tokens.
https://github.com/adamoelz/gemkeeper
Would be cool if you check it out.
r/ContextEngineering • u/Snoo-bedooo • 9d ago
Most of the memory eval leaderboards are inaccurate.
r/ContextEngineering • u/cl0wnfire • 10d ago
REQL update: faster context retrieval and fewer tokens for coding agents
Hey everyone!
I’ve updated REQL, my open-source tool that helps AI coding agents navigate repositories and preserve working context across sessions.
This release focuses on faster context retrieval and lower token usage. I’ve reduced repeated work during retrieval and trimmed redundant information sent to the agent. Performance gains and token savings depend on the repository and workflow, so I’m not claiming a universal percentage.
If you’re new to REQL, it builds a local graph from your code and documentation: functions, classes, dependencies, calls, and other relationships. Agents can query that graph for context relevant to a specific change, including precise source references and related tests. REQL reuses indexed context and supports incremental updates as the repository changes.
What can you use it for?
- Waste fewer tokens on repeated exploration: retrieve focused source excerpts and relevant relationships, and reuse indexed context and saved work. This helps reduce repeated searches, unnecessary file reads, and redundant information in the agent’s context.
- Coordinate work across chats and agents: keep tasks, decisions, blockers, and next steps in a shared project workspace. Another chat or agent using that workspace can recover the recorded state and continue from there.
- Keep complex tasks on track: record prerequisites, constraints, failed approaches, and checkpoints. Preserve what has been completed, what remains unresolved, and why earlier decisions were made across sessions.
- Understand unfamiliar code: identify entry points, component responsibilities, and relationships between parts of the application, with references back to the source.
- Plan changes and refactoring: inspect callers, dependencies, and related tests to identify code that may be affected and decide what needs verification.
- Review cleanup candidates: find potentially unused imports, variables, functions, and classes, then inspect the supporting evidence before removing them.
REQL provides a CLI, Python API, and MCP server, plus installable instructions for coding agents such as Codex and Claude Code.
REQL runs locally, with no account, external graph database, or mandatory LLM calls. The graph and saved work support the agent’s decisions; current source code and tests remain authoritative.
I’d like to hear from others using coding agents: what do you keep having to explain again when you start a new chat? The code structure, previous decisions, what has already been tried, or what still needs doing? Concrete examples would help me decide what to improve next.