r/opencode • • 6d ago

After about two months of extensive usage of Deepseek 4.1 Flash I think i understand why it gets dumber for some people - it is the context window

from my anecdotal observations, deepseek 4.1 flash (and 4.1 flash 1017) performed best when the context-window is under 400K, as soon as you go beyond that you will realize it gets more and more confused as the context window grows.

I would say around 700K+ it becomes unusable bad. so, you either use a context-management plugin that have some kind of virtual limit to cap the context around 400K. or start a new session as soon as it reached about 400k-500k. and you usually want to be more careful with what you stuff into the context - if you have a lot of random, non-focused tasks in the same context, it will become even worse at > 400k.

I think this is partly because of DS 4.1 flash used a lot aggressive compression techniques, including sharing KV cache between multiple layers so anything that fall in between become very lossy.

142 Upvotes

49 comments sorted by

41

u/CaffeinatedTech 6d ago

Yeah I've been telling it to start wrapping up and preparing a handoff when its context gets to around 300K. It does a fairly good job of it. Often I will run it as an orchestrator using subagents for all of the work, tests, adversarial reviews. The orchestrator just runs autonomously until it gets to around 300K then stops.

10

u/megablue 6d ago

yes, i found that around 300k is the sweat spot as well. it can get slightly beyond that if i have larger task to complete but i always make sure it never gets above 500k.

3

u/xmsxms 6d ago

Just set auto compact to whatever size you need.

7

u/CaffeinatedTech 6d ago

I don't like auto compact. I can't trust the context that survives, and I like a clean session every run.

33

u/OptimalLengthiness42 6d ago

Damn you people really live like this? The moment I get over 100k tokens I start planning how I'm gonna handoff and compact. Rarely do I hit 200k and that's usually a sloppy mistake on my end, 125-150k is usually my hard cap.
What are you all doing at 400k?

11

u/megablue 6d ago edited 6d ago

i wrote and experimenting with multiple context-management plugins so far i find limiting the context to 300K is the sweat spot, then my plugin would summarize + compacting the previous turns and rebuilt the last turn. 100k -200k is doable but you will waste a lot of tokens on cache misses due to you constantly invalidating the prompt cache.

22

u/zarafff69 6d ago

Make GTA7 make no mistakes

4

u/Standard_Ear_84 6d ago

Large files seem to be one avenue.

4

u/FailedGradAdmissions 6d ago

Add a lint rule for refusing to commit large code files, and if you have large data files, put that into something like SQLite or another DB and have your agent query it instead of wasting tokens

1

u/xmsxms 6d ago

But it doesn't/shouldn't read in the whole file into context. Just a reference and a window.

3

u/Standard_Ear_84 6d ago

Initial conversion is unfortunately one case where a lot of reading is required to confirm formatting is okay. And sometimes DS just reads everything for no reason instead of using grep.

4

u/Dudensen 5d ago

I mean it depends on what you are doing right? If I vibecode based on existing files I almost always hit 100k-150k in the first turn.

3

u/aravyne 5d ago

You could have the build agent create a docs/ folder with documentation about the project architecture in separate .md files, and a rule in agents to always keep the documentation up to date. Really lowers your token count when vibin and doesn't need memory plugins.

3

u/ProgressionPeak 5d ago

i hit 400k on the reg

its just large codebase that does it, i presume. it takes me maybe an hour of serious work.

0

u/thesomeotherguyss 4d ago

huge codebase man.. but i agree it's a skill issue, because I deliberately tell fresh ai to explore codebase first to understand the nuance of the project.

2

u/bullraiii 6d ago

Personnellement je n'ai pas de context à plus 200k et plus de 100k très rarement. Une demande, un patch, une nouvelle feature =nouvelle conversation. Pour des grosse demande (création d'une app), je créer un plan long-terme et chaque étape est une conversation. Vous fait comment pour avoir des contexte à plus de 300k ? Sérieusement, je suis curieux.

4

u/megablue 6d ago

for simpler tasks, 100k-200k is easily doable, but some long running/complicated tasks simply do not fit in 100k-200k context window. just the back-and-forth plannings already taken up 100k-200k

2

u/bullraiii 6d ago

Haaa vous faites tout dans la même conversation... Je comprend mieux. C'est pour sa que je sépare discussion, plan et build... Essaye une fois et tu verras la différence

1

u/megablue 6d ago

it doesn't make sense to keep opening new session every few prompts, you are wasting a lot input tokens and invalidating the prompt cache. if you do that, it is almost as if you are using the web chat (yes i used to do that with web chat), it kind of defeating the purpose of having a harness.

1

u/bullraiii 6d ago

J'ai menti, une documentation dédié à L'IA et le changement de conversation, as divisé mon utilisation de token.

1

u/megablue 6d ago edited 6d ago

i dont think you understand what i meant. reduced token usage doesn't actually mean much. the expensive part is the input tokens that missed the cache. with your way, it seems to look like you are saving tokens but in reality, you are actually paying way more (or getting way less usage from Go) because of you keep opening new session. cached tokens are very cheap but input that missed the cache is expensive.

1

u/bullraiii 6d ago

J'avais bien compris se que tu dis. Je te partage mon constat. Je vais développer un peu. Avant je discuté d'un patch, je fesais le plan et je build dans la même conversation. J'étais à 300/600k avec des erreur. Maintnant je suis à 200k sans erreur. Le fais de changer de conversation retire le context 'parasite' et j'ai remarquer que plus ma demande est claire et structuré moins il a besoin de cherché dans le projet. La documentation sert à indiqué à L'IA ou et quoi chercher pour le patch que tu veux appliqué( il regarde seulement le code utile) , donc le context d'entrée est grandement réduit. Je ne dis pas que j'ai raison, je partage le constat que j'ai remarqué sur mes facture depuis mes changements de workflow .

1

u/bullraiii 6d ago

J'ai diviser par 3 mon utilisation de token.... Le plan que tu fait est suffisant pour un build, pas besoin de context.

5

u/PerfectReflection155 6d ago

That’s interesting OP. It wouldn’t surprise me as I’ve seen some say models can really keep on track properly after only 200k context.

Also the other thing is I don’t understand why people simultaneously complain about running out of credit fast and still use the default 1M context window. Do they not understand how much tokens it is using ?

I have mine at 150k in Pi primarily to save on token spend and rarely have any issues. In Pi I use smarter compact and opencode I use magic context. I actually have it at 200k context limit for opencode which is probably a better balance.

I don’t have any issues with it getting dumber ever. My only complaint about deepseek is it does seem to take a long time to complete some tasks where another model could probably do it twice as fast.

But I knew that going in it can be slower what matters more is accuracy and getting it done properly and deepseek is performing well on that.

5

u/beardedNoobz 6d ago

Yeah, that is a common issue with most Chinese models. I remember in 2025 where most context windows is 262K~ish, GLM 4 and Deepseek 3 series keeps going bad past 100K context. The fact that they can manage 300-400K~ish context without going dumb nowadays is a real progress.

1

u/Anh-DT 6d ago

What do you mean max context is 700k anyways. Input is 300k+ total 1m

5

u/megablue 6d ago

the max context window is 1M for deepseek 4.1 flash go and zen.

2

u/Anh-DT 6d ago

Yes but it's split context 1m total output and input context

4

u/megablue 6d ago edited 6d ago

the free version is 200k but usually you can go slightly beyond, about 230k.

2

u/amyoeba 6d ago

you can make a skill to compact itself at boundaries between units of work. i have it set to compact every time its PR merges before starting the next feature

1

u/fapmasterr69 5d ago

Could you let me know how to do it?

2

u/Early-Crazy-4246 5d ago

Just tell your agent, "Hey dude can you make me a skill that compacts the context window any time you merge a PR"

2

u/Green-Recording6578 4d ago

After a full day of testing yesterday (200M+ tokens consumed), I noticed the same issue with the 1M context window: the model gradually loses track and becomes significantly slower.

I reduced it to 300K tokens, and performance improved noticeably. The model became faster, more consistent, and better at maintaining context.

I'm using an API key through VS Code's local harness, which automatically compacts the conversation when the context reaches its configured limit.

3

u/sayboom 6d ago

Based on my observations even 200k tokens its too much in average and deepseek starting to degradate

2

u/gugugaga_069 5d ago

even pro models like opus and sol goes dumb after 400k mark , its all about context management , if that is good even Qwen 27b model can code better

1

u/cdcyberdream 6d ago

same here

1

u/mWo12 6d ago

I use billion-context to help with keeping context under control.

1

u/mad_vik 6d ago

Comment connait on le poids du contexte ?

1

u/m2wm2wm2w 6d ago

Thanks for this, I had a long running session and was getting infuriated at how dumb it was getting. Should have made the connection that new sessions worked perfectly well, but a few were going off the rails.

1

u/Minimum-Drive-3571 6d ago

I wrap up around 150 to 200k. That way the usage drops very low.

1

u/ProgressionPeak 5d ago

i reset the context constantly so this isn't the answer for me

i suspect its inference providers using some shit version of it

1

u/fapmasterr69 5d ago

So how do I set it up to for session compaction without using auto compact limit? I'm hitting the full context window limit very often and had some minimal trouble yesterday with DS hallucinating, nothing that I couldn't fix but I'd like to be on the safe side in the future.

1

u/warpaint_james 5d ago

Yep. I compact before 50%. Anything after that is usually a big drop in quality

1

u/6T_K9 5d ago

Yeah this has been known for a while between the power users. I’ve been having the best experience by putting the cap at 350k so that it usually starts compacting around 300k. That’s the sweet spot imo.

1

u/Jakkaru3om 3d ago

This is well known and should be a practice everyone follows. I always try to keep context under 150-200K 300max anything above that I do not trust. I use matt pococks skills and when it is time to do to-tickets I tell it to break them down in a way that would keep the implementer subagents around 150-200K tokens.

1

u/xenstar1 3d ago

I set an auto-compact rule at 272K.