

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
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
I like to think of my session contexts more as "resources" than "conversations." They're ultimately logs of text, so it's easy to build tools for manipulating them. Just like git makes manipulating code changes super powerful, some agent session management tools can edit session context in ingenious ways.
The /undo command rolls back the last response the model gave you. If OpenCode captured a matching filesystem snapshot, it also restores the files changed by that response!
After running /undo and before submitting another prompt, you can use /redo to restore the conversation and files to the state that you just rolled back from. That said, submitting a new prompt makes the undo permanent, so you can no longer redo it!
OpenCode's snapshot capture requires a Git repository and is on a best-effort basis. /undo can't reverse all side effects of shell commands, e.g., changes to databases or files outside the working repo, effects on running processes, and network operations. So, it's a convenience, but not a replacement for good Git hygiene and backups.
I actually use /undo quite a bit. If I get a "bad" output, and I can tell it was just a bad prompt, a quick undo + re-prompt is a lot faster than trying to explain to the AI what went wrong and how to get back on track.
Undo and restore a small test addition.
Unary minus should reject a boolean, so this SlopLang program should produce a runtime error (the ✅ emoji is true in SlopLang):
hallucinate(-✅)✨
While this is okay:
hallucinate(-1)✨
Tell OpenCode to run and submit the CLI tests from the project root.