Artifacts as Intentional Compaction
I want to talk about "artifacts"—the files that AI writes for us—and why I think of them as intentional compaction, a term I'm borrowing from Dex Horthy. I think this framing is brilliant and I want to explain why.
Regular Compaction vs. Intentional Compaction
With regular compaction, we are asking the LLM to decide what is important to keep in the context, and ditch everything else.
When we write an artifact, we are asking the LLM to write out what is important to a file, and then we clear the context.
These are remarkably similar, with a few small key differences.
Why I Prefer Artifacts
There are times when compacting makes sense, and I may still do it. However, for an important task, I prefer to use an artifact because I can see what it has in it, review it, ask for certain details to be removed or added, and get the "perfect context" for the next step.
With a compact command, I just get what I get, and we move on to a new chat history.
Multi-Session Power
Another feature of artifacts is that I can do multiple research sessions, or coding sessions, and pass multiple artifacts into a new chat session as the starting context and it will fit. This is super useful for doing difficult or long tasks which would never fit in 1, 2, or even 3 sessions normally but now easily fit in 60k context when sent in as "artifacts."
To do this with compact, we are compacting the prior sessions each time and I would be concerned that since the most recent messages were about a different focus, we would end up compacting some of the key details from previous sessions.
The Bottom Line
This is why I generally prefer artifacts over compaction. However, you may use compaction for a focused session and eventually write an artifact. That is valid in some cases and it's up to the engineer to decide what they need in the moment.
This is your new job. Decide how to use the AI agent and its context effectively to accomplish your goal.