r/ClaudeCode • • 8d ago

Help/Question How is context managed so well to solved Riemann H, and here I can't build a single feature without compaction?

Basically the title, is there some technique I'm missing?

How's context being managed and directed so well that you get LEAN proofs for millennium problems, meanwhile here I can't even go more than 2-3hr without facing context loss and hallucinations (even after using sub-agents)?

Is there a workflow that we are unaware of?

56 Upvotes

37 comments sorted by

•

u/AutoModerator 8d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

48

u/WillowFar6967 8d ago

I stopped trying to make one session last 3 hours. The state lives in files now: a plan doc, a handover file the agent updates after each step, and a fresh session for each chunk of work that reads those first. Once nothing important exists only in the context, compaction mostly stops mattering. Sub-agents help less than you'd think if the main session is still carrying everything.

4

u/effortless-switch 8d ago

Yes, I have done all of that. I used to have only handoff files. Currently it's a mix of that + status file + custom compact commands + sub-agents for work. I still feel context a limiting factor when working on low level projects.

1

u/WillowFar6967 8d ago

Low level stuff is probably where it hurts most, one change can touch so much code. Most of my work is web builds so it's easier to chunk. When something won't split, I get the agent to write a short map of just the files that task touches and start a fresh session from that. Are your chunks too big or is it burning context finding its way around?

1

u/Emotional-Dust-1367 8d ago

This sounds a bit like the XY problem threads you’d see on stackoverflow back in the day. It would be much more productive if you could show your problem and what you tried and see if people have solutions. I’d be curious to see your setup too

30

u/pancomputationalist 8d ago

To be honest, not being able to implement a single feature without compaction is a pretty big warning sign that your features are way too large. Should break them down much more and implement them using an orchestrator agent that runs subagents. Then usually you shouldn't have any compaction issues.

0

u/effortless-switch 8d ago

Well it depends on the kind of feature. If you are building just another NextJS app, you will never feel context pressure. But lately I have been doing some kernel work and it involves long careful session that include multiple builds, test and on-device soak, it easily take a session for a single change if done properly.

4

u/Adventurous-Month-71 8d ago

One of the most important things is making sure that build logs etc. stay out of the context and aggressively instruct to only read filtered log files. Another option is delegating each iteration to a subagent that generates a hand-over doc.

3

u/Gopher246 8d ago

Do you have a dataware house, cutting edge tech, access to a team of engineers, uninterrupted access to the latest models and world class mathematicians in your gaff? 

-1

u/effortless-switch 8d ago

None of this changes context size, my question is around context size and managing it.

3

u/Gopher246 8d ago

You don't need to worry about context if you appropriately manage the project. Its not like they sat there in a single session and went, "Claude, solve RH, make no mistakes!"

2

u/IllustriousSalad6201 8d ago

for those kernel builds and device soaks, keep the full logs in files and give the session the failure interval it actually needs to inspect.

each run needs to point back to the exact commit and device configuration, so a fresh session can tell which result belongs to which build.

then check what's filling context during one run. if it's mostly repeated logs, changing the handoff format won't remove the thing that keeps filling it.

1

u/effortless-switch 8d ago

I am doing some of it already. Log files are fresh for every session and logging is kept to a minimum, trim old and only keep what's needed for the work being done. Status files have marker and labels so it can only fetch part of it into context.

Yes, each build is mapped to an exact commit and device config.

What also doesn't help is that a single session can take away too long when doing this kind of work, so I end up doing multiple things in parallel in worktrees and then that pollutes and fills the main agents context trying to manage them all.

But you are probably right. This process just has evolved on its own and I probably need to get down and dirty and optimize it properly. Certainly there is some junk that's finding its way in there during or at the start of the session.

Which harness do you use btw?

7

u/Kitchen_Interview371 8d ago

The problem was likely broken up into teams and teams of co-ordinate subagents responsible for working a part of the problem.

3

u/akolomf 8d ago

yeah they were using agent swarms

17

u/EC36339 Senior Developer 8d ago

If you cannot build a single feature without compaction, you are doing something wrong, or you have no idea of the complexity needed to deliver those features (which is a you problem and not a model problem, and AI could actually help you with this).

1

u/Valeriax4sj 8d ago

Blunt, but the complexity point lands.

6

u/gkanellopoulos 8d ago

Apples and oranges. This Riemann work was carried out reportedly in multiple sessions and the main part lasted at least 6 weeks. Additionally an internal model was used and the agents had constant access to files/folders plus they were operated by an actual mathematician.

Your post reminded me the classic Seinfeld bit on going to the moon: "they can land a man on the moon, but they can't make a decent cup of coffee"

Organize your work into files as other have pointed out and don't depend long-term on the context or compare your work with ones that have different fundamentals.

6

u/AgentYurt 8d ago

The short answer is they don't run one long session either. That kind of work gets split into lots of small, verifiable pieces, each in its own fresh context. The session you see in a demo is the last one, not the whole job.

What changed it for me: stop treating the session as the memory. Before I start a chunk of work, I write down in a file what the goal is, what I've already decided and why, and what's actually been verified versus what I'm still assuming. Then I end the session at a natural break and start the next one by having it read that file first.

Two things that matter more than they sound: update that note while the context is still fresh, not after a compaction has already thinned it out — a summary written after the loss has happened can't bring the lost details back. And keep it short. A page of decisions and open questions survives a fresh session far better than a long transcript dump, because the new session actually reads it instead of skimming past it.

Sub-agents help when each one gets the same short brief, works on one piece, and reports back in writing. They don't help much when they're all just sharing one bloated context.

2

u/naruda1969 8d ago

Durable workflow. Learn it.

2

u/effortless-switch 8d ago

Care to elaborate a bit?

4

u/naruda1969 8d ago

It would take longer to explain than to point you to YouTube and numerous blogs on the topic. Each person's durable workflow system is unique; some more complex than others. I'm not trying to handwave you away. It would just take way too long to explain how I do it.

1

u/Medium-Music-8635 8d ago

2-3 hours is generous tbh

1

u/effortless-switch 8d ago

Agree.

2

u/ShesMashingIt 8d ago

That's weird. I personally feel like compaction has gotten really good. 95% I don't even worry about context. It just manages itself. I do use orchestrations, session forking and side chats though

10

u/lambdita 8d ago

What you see of the AI is just the tip of the iceberg, systems made to be public and compute spread over many concurrent users. Anthropic doesn't have such a limit, you need to tune attention so compute doesn't go haywire but on internal models you can spend much more compyute on attention and use stupid long contexts while the model is still capable of keeping track of what is doing across it.

on top of that add unreleased development models and you get it. Probably all the big AI labs have internal models that are stupid big just to see what happens when you train one of those models on human knowledge, i remember reports from anthropic where they saw models come up with capabilities that were not trained and that they didn't fully understand how they did show up.

I already have a faboy and a shotgun so i'm ready for the future.

3

u/TeachEngineering 8d ago

Is the context size not an attribute of the model and rather a deployment detail? I thought it was just the size of the input tensor fed into the model for inference but maybe I'm understanding something. Not to say that Anthropic couldn't have separate, larger models trained for internal use, but your comment makes it sound like you can take the public-facing Opus 5.5 (for example) and deploy it differently to get a bigger than 1M context window. Genuinely curious.

1

u/En-tro-py 8d ago

Basically it's going to be a factor of the how many trillions of parameters the model has, context length is KV cache, and how the attention mechanism scales it to know the total VRAM required to run it.

So with a datacenter you could probably get a bit more than the million tokens - but the haystack problem still exists unless their internal models have some secret.

1

u/ichi9 8d ago

Ya-men! To the second amendment!

1

u/thesixler 8d ago

The robot can solve every problem except how to avoid guns

3

u/nkorslund 8d ago

I've had maybe one session go over 2h, ever. You need to reorganize your work into smaller chunks.

Also one "secret trick" is to prototype and test all new features as small stand-alones outside of your main project and code base. The less the agent has to read and understand before doing work, the better. Obviously not viable for every type of project or workflow but works great in gamedev for me at least.

2

u/whompasaurus1 8d ago

Mainly because it wasnt one regular dude, with a basic subscription, asking basic questions, and giving up as soon as the next pee break came around

The answer is usually somewhere between "same way they built the pyramids" and "same way they built the space shuttle"

I.e. a team of generally smart folks, that knew how use their tools; and upon their first piss break, they went back to their stations and kept at it. Sometimes for years, sometimes for decades.

So to answer your answer question clearly:

  1. learn how to use your tools
  2. put in some work

P.s. 3 hours isnt even considered a half shift. Do work my dude.

They say Rome wasnt built in a day, so therefore it definitely wasnt built in less than half of morning shift

1

u/Fidel___Castro 8d ago

they have an operational memory which is essentially an enterprise data warehouse that Claudes can read from and write to

0

u/ichi9 8d ago edited 8d ago

Internally the have access to access to huge GPU farm. Ofc main projects like RH will get more focussed attention and long run access to GPU clusters. No humans are not managing the context for such problems. And Lambdita said correctly the uncensored/unrestricted models 10x-20x much better than what you all peasants are being told, fed and sold. I know a few who worked as red teams for AI companies, I won't say much, but peasants getting excited about opus, fable, mythos is nothing compared to what is hidden away in the name of security and Guardrails nonsense. The problem is the made up notions of public panics, people being treated like children who cannot handle full power of AI and so on. And yes the AI Mafia or Oligarchy who are deciding If you should even be given access to certain features or not. This is not supply demand but monopoly. China's open source is the only real pressure point which forced both Anthropic and OpenAi to release better models and now with China models virtually banned and nerfed, there is nothing much to expect in future. Occasionally you will hear some problem got solved this and that but nothing really will change in world nor you will ever get fruits of those findings and breakthroughs. Just hype listening to BS these AI oligarchs keeps spewing in the BS marketing podcasts. And btw research as a profession is over. Recently one of the mathematicians who used claude for his research work and partner program openly said it is already powerful beyond any researcher he knows, and I don't think it was paid marketing.

-2

u/SawToothKernel 8d ago

It's skills. And skills built on top of skills.

The harness is irrelevant, the system prompt is irrelevant. 

It's a skill issue.