r/ContextEngineering • • 17h ago

Unmanaged agents reused existing components only 55–59% of the time in million-line codebases. With a context layer, 92%.

Thumbnail
leaddev.com
2 Upvotes

Context is where the hours go.


r/ContextEngineering • • 23h ago

AI Context Vaults for GTM/Customer Success

Thumbnail reddit.com
1 Upvotes

I 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 • • 1d ago

Jev for Context Assembly

Post image
6 Upvotes

r/ContextEngineering • • 1d ago

Shared team context across AI conversations through MCP

Post image
1 Upvotes

r/ContextEngineering • • 2d ago

I spent months making repository context smaller. Then I found out fewer tokens doesn't always mean cheaper agents

2 Upvotes

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:

  1. Whether the correct information reaches the model.
  2. How many tool calls the agent needs to find it.
  3. How much additional reasoning or searching the supplied context causes.
  4. Actual end-to-end cost and latency.
  5. 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 • • 2d ago

Keeping the original: why my memory layer never edits what you said

1 Upvotes

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 • • 3d ago

Agent handoffs: what do you re-check before you trust what the last run says it did?

2 Upvotes

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 • • 3d 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?

1 Upvotes

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 • • 3d ago

How to find one memory in 60 million tokens - lessons learnt from building AI memory at scale

Thumbnail
reddit.com
1 Upvotes

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 • • 4d ago

Scheduled-agent folks: how do you catch a run that finished green but did the wrong thing?

3 Upvotes

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 • • 6d ago

We str8 up made a memory for.my.agent from scratch tonight that uses minimal tokens

Thumbnail reddit.com
1 Upvotes

Here'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 • • 6d ago

Does your context compression survive the prompt cache? I built a deterministic compressor for Claude Code and Codex

0 Upvotes

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 • • 6d ago

I built a memory for AI coding tools that notices when it's out of date, and now teams can share it

Thumbnail
reddit.com
2 Upvotes

r/ContextEngineering • • 6d ago

We’ve built RAG chatbots on both Pinecone and pgvector. Here’s when each one actually wins.

Thumbnail reddit.com
1 Upvotes

r/ContextEngineering • • 7d ago

Claude Code skill: better memory than /compact, 85% fewer tokens

Post image
1 Upvotes

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 • • 7d ago

Most of the memory eval leaderboards are inaccurate.

Thumbnail
reddit.com
1 Upvotes

r/ContextEngineering • • 8d ago

REQL update: faster context retrieval and fewer tokens for coding agents

2 Upvotes

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.


r/ContextEngineering • • 9d ago

Building an AI platform with a small team has been quite a journey.

Thumbnail
reddit.com
2 Upvotes

r/ContextEngineering • • 9d ago

Universal Code Intelligence & SDLC RAG Service for AI Agents

Thumbnail
reddit.com
2 Upvotes

r/ContextEngineering • • 9d ago

Want to learn more about memory management in Agent

Thumbnail reddit.com
1 Upvotes

r/ContextEngineering • • 10d ago

A user tested my AI platform and caught an interesting problem.

Thumbnail
reddit.com
0 Upvotes

r/ContextEngineering • • 10d ago

I'm opening my personal-context librarian to 10 testers. What would you use a shared agent memory for?

0 Upvotes

A while ago I posted here about a librarian for my personal context, and a few of you asked to try it.

I built it, it's called Zenod, and you can try it today.

What it does: it keeps what you learn and what's true about you as plain Markdown in your own GitHub repo or Google Drive. Claude, ChatGPT, Cursor or any MCP client read and write the same memory.

What I'm asking: use it for real for a few weeks and tell me what breaks.

What you get: one free month, no card. I was going to pick testers by hand, then realised I'm the slowest part of this, so the first ten who apply are in straight away.

Apply here: https://zenod.dev/testers?s=P-0146

How are you going to be using it?


r/ContextEngineering • • 11d ago

Finally introduced coding subagents to my harness

Post image
2 Upvotes

I was running several primary agents in parallel across multiple projects and the notifications were burying me. Every agent stopped to ask me something: "X or Y?", "found a side issue, fix now or later?" etc. I had become the bottleneck. my AGENTS.md cover many conventions/rules/standards but its still wasn't enough to cover so many of these questions.

So I restructured my workflow like a team:

  • Me: the manager
  • One chat per project: the team lead
  • The other agents: team members, each working in its own "lane"

How lanes work

  • A lane is a git worktree plus a chat working inside it. Each one gets its own branch and folder, so agents don't trample each other's files.
  • The lead asks to open a lane with a title, a plan, and the files it expects to touch. Nothing starts until I approve it on a Lanes board. Before I approve, the harness checks for overlap with files other open lanes are touching, my plan usage, machine load, and whether a spec exists for the work.
  • When a team member stops (it's done, blocked, or has a question), it rings the lead, not me. The lead works through its inbox and replies.
  • The lead can only answer from written rules: a lead.md file in the project plus the project's docs, and it has to cite the rule it used. If no rule covers the question, or it's a taste/preference call, it escalates to me.
  • Escalations land on the board and on my phone as numbered questions, each with a recommended answer. I can answer straight away or ask the lead a follow-up first.
  • The lead can also send me FYI notes that don't need an answer.

I still have full control

Every lane is a normal chat. I can open any of them, read the whole transcript, and type into it directly if I want to step in. The harness never merges a branch, deletes a branch, or removes a worktree on its own.

My notifications are now mostly things that actually need me. It's still early, and I keep refining what goes into lead.md, since that file decides how much the lead can handle without me.

So far I have noticed I am getting a lot more done with less headaches. (literally!)


r/ContextEngineering • • 11d ago

Every request pastes your whole AGENTS.md into the prompt. Mine grew until the agent started butchering it

0 Upvotes

If you use Codex or Claude Code, you have a context file — AGENTS.md, CLAUDE.md, .cursor/rules. It gets injected into every single request, so it's both a token cost and a permanent tax on how much room the model has left for your actual work.

Mine grew the way these files always grow: one justified-looking addition at a time. Then it hit a size where the agent started dealing with it by rewriting the file from memory, dropping the ## Never rules, and shipping something worse. You find out weeks later when a rule stops being followed.

So I wrote ctxcap. It counts tokens across those files, tracks the count against a committed git baseline, and flags references that no longer point at anything. Offline, no API key, no network, no LLM, two dependencies. MIT.

bash

The part that makes it more than a word count: it doesn't tell the agent "make this shorter." It emits line ranges with a preserve list, the agent splices by line number, and --verify catches drift or a cut preserved span. When the budget can't be met it returns satisfiable: false with the minimum achievable rather than shaving a rule that matters:

It uses gpt-tokenizer, and there's an MCP server so the agent can measure itself, plus a GitHub Action that comments the token delta on PRs and only fails when you set a budget.

https://github.com/Naeha-S/ctxcap

The question I actually want answered: how long is your AGENTS.md, and what's still in it that earns its place? Mine is the one file where every addition felt reasonable at the time.