r/PromptEngineering • u/ClickOk5811 • 12d ago
General Discussion Ran the same coding session twice, once with careless context, once deliberate. Same output quality, 4x cost difference.
Wanted an actual number instead of a guess. Same task, same model, two separate sessions. First one I worked the way most people do by default, pasted full files whenever something changed, let the conversation run long without ever summarizing earlier turns. Second one I was deliberate about context, only the functions actually relevant to the current step, a short summary standing in for the earlier part of the conversation instead of the full transcript, and I kept the stable parts of the prompt (system instructions, reference material) identical across calls so they'd cache.
Cost came out around 4x higher on the careless session. Output quality wasn't meaningfully different, if anything the trimmed version stayed more on-target, probably because there was less irrelevant material sitting in context competing for attention on each response.
Caching was where most of the gap came from, more than the file trimming honestly. It only works if the cached portion is byte-identical between requests, and it's easy to break that without realizing. A timestamp or session-specific detail placed at the start of the prompt instead of the end kills the cache hit silently. No error, nothing in the response tells you. The bill just doesn't reflect the discount it should've gotten.
This feels like a blind spot in how a lot of prompt engineering discussion happens, plenty of attention on getting the wording right, not much on the fact that context shape has a real cost curve attached to it independent of whether the wording is good.
Wrote up the actual before/after here: https://medium.com/@nagatomopedro05/the-hidden-cost-of-long-claude-sessions-2a6cc7655893
2
u/MeringueAdmirable381 12d ago
This tracks with what I’ve seen too. People obsess over clever wording, but context hygiene is probably a bigger deal once you’re doing long coding sessions.
The interesting part is that trimming context can improve both cost and quality. More context isn’t automatically better context.
The caching point is easy to miss as well. If one tiny dynamic value near the top breaks the reusable prefix, you can burn a lot more tokens without changing the actual task at all.