We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Context As RAM

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.

Managing Context in OpenCode

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.

Assignment

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.