

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
click for more info
Not enough gems
Cost: 6 gems
1: What Is Context?
incomplete
2: Context As RAM
incomplete
3: New Sessions
incomplete
4: Token Economics
incomplete
5: Ignoring Files
incomplete
6: File Watcher
incomplete
7: Lost in the Middle
incomplete
8: Compaction
incomplete
9: Configure Compaction
incomplete
10: Undo and Redo
incomplete
11: Forking
incomplete
12: Secrets in Context
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Just like RAM is the working memory of a computer, it's useful to think of a model's context window as its memory.
You wouldn't slow your computer down by hoarding tabs, would you? Then why bloat your context window?
Or if you are a tab-hoarder like me, hopefully you at least understand it's not ideal.
The "Context" section in OpenCode's right-hand sidebar shows your current context usage in tokens and as a percentage of your model's maximum.
When your agent goes about reading files, fetching data from the web, or using tools, it's storing all that data (or sometimes a summary of it) in the context window. Remember how we talked about how each token prediction is a simple pipeline?
input tokens -> model -> next token
Well, if your input is full of irrelevant information, not only will it make your inference slower and more expensive, it can also confuse the AI and make it more likely to generate a bad response.
Agents are pretty good at figuring out what files to load, what folders to look in, etc. Just make sure your prompt has as much relevant info as possible.
When you're explaining a task to a coworker, you don't bring in the story of your latest failed romantic endeavor (I hope). You just give them the details needed for the task at hand. That's also how you should treat your LLM's context.
There's a comment-line counting bug in sloperator/lexer/scanner.py! This "code":
— a comment
@
Should report a lexical error on line 2, but the lexer reports it on line 1.
Then tell OpenCode to run and submit the CLI tests from the project root.