My agent kept forgetting my instructions, so I built it a haunted city

2026-12-05来源 dev.toEnglish
My agent kept forgetting my instructions, so I built it a haunted city

How many times has your agent compacted on you?

How many times has your coding agent compacted on you?

You're an hour into a session. The agent knows the codebase, knows what you asked for, and knows the handful of rules you set along the way: no new dependencies, don't touch the public API, that sort of thing. Then the chat gets too long, it gets squashed into a summary, and something quietly changes. A while later it installs the one package you said not to.

Nobody tells you the rule was gone. The summary just didn't have room for it.

That's what I built Blackout for, in Kiro.

Midnight: the clock strikes and the chat is compacted

What it does

Blackout is an MCP server and a Kiro power. It keeps what the agent knows outside the chat, where a compaction can't reach it:

  • It maps your repo into a graph: every folder, its files, every import between them. A read-only audit writes down what each folder does, so after a compaction the agent can ask instead of re-reading everything.
  • It files your rules on the folder they govern, in your exact words.
  • It checks every compaction. When Kiro writes its summary, Blackout holds it up against the ledger and calls each rule kept, weak or lost.
  • It puts back only what was lost, word for word, labelled by who set it.

Then it draws all of it as a haunted toon city: folders are buildings, rules are lit rooms, imports are wires, and a compaction is midnight, when the lights go out street by street.

Explore: open a building like a dollhouse and read its rooms

Every rule is a paper notice pinned to a wall in the folder it governs, word for word:

A rule pinned to the wall, word for word

And the same codebase as a graph, or as a map:

The graph view: folders, files and rules

The map view

A real session

I installed Blackout from npm into a fresh Kiro, opened the Blackout repo itself, gave it three rules, and kept working until Kiro hit 79% of its context and compacted on its own.

Kiro compacts the chat, and Blackout's hook puts back what the summary lost

Blackout's PostCompact hook checked the real summary. All three of my rules came through, but ten facts about the code had been blurred or dropped, things like which function guards the folder paths. It put all ten back.

Then I tried to break it and asked Kiro to add chalk. That's a new dependency.

Kiro refuses, and quotes the rule back

Kiro said no and quoted my rule back at me.

How I built it in Kiro

Everything except the 3D city assets was built in the Kiro IDE.

  • Spec first. I started with a Kiro spec: requirements, then design, then a task list I worked through. It forced me to decide what "kept" and "lost" actually mean before writing any code.
  • Steering kept the agent on my conventions across a long build: how the backend is laid out, how the viewer works, the camera rules for the film.
  • Hooks are the heart of it. Six of them: UserPromptSubmit files rules from what you type, PostToolUse tracks which files are in context, PreCompact and PostCompact wrap Kiro's compaction, PostFileSave flags stale audits, and Stop checks the turn against your rules.
  • MCP gives Kiro 22 tools to map, audit, file, check and restore.
  • A power packages all of it, so setting it up is one npm install and a copy into .kiro.

The meta part I liked most: I was building a tool about agents losing context while my own agent was losing context. Blackout ended up guarding its own build.

The import graph drawn as a constellation over the city

Does the check actually work?

Marking a rule kept, weak or lost is a text comparison, so I measured it on 143 hand-built compaction cases. It caught 96% of the rules a summary dropped or blurred, and on the cases I held back from tuning it never re-sent a rule that was still intact.

Try it

Your codebase is next.

原文:https://www.a8q9.cn/en/article/my-agent-kept-forgetting-my-instructions-so-i-built-it-a-haunted-city-44799a.html

相关文章