tell the stop gate that already-stored is a valid outcome - #35
Merged
Conversation
The gate fired on the two memory files this session had just written, and its reason offered exactly two ways out: write the facts, or declare the file holds nothing durable. Neither was true. The facts were already in the graph - write_episode ran earlier in the same session, before the files existed, which is what the MCP tool description asks for. An agent following that text literally writes the facts a second time. And this is not a corner case: the documented workflow is write_episode in the turn the thing happens, and Claude Code then writes its own memory file, so every well-behaved session ends with a queued file whose content is already stored. A gate that fires on correct behaviour and then asks for duplicates is a gate people switch off, which was the one failure mode the bounds exist to avoid. The reason now names three outcomes, all ending in marking the file done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by the gate firing on itself, one hour after #33 shipped.
What happened
The Stop hook fired on the two memory files this session had just written. Its reason offered exactly two ways out:
Neither was true. The facts were already in the graph —
write_episoderan earlier in the same session, before the files existed, which is exactly what the MCP tool description asks for ("call write_episode IN THE SAME TURN whenever...").An agent following that text literally writes the facts a second time.
Why it matters more than it looks
This is not a corner case, it is the documented happy path.
write_episodein the turn the thing happens, then Claude Code writes its own memory file — so every well-behaved session ends with a queued file whose content is already stored. The gate would fire on correct behaviour, every time, and ask for duplicates.That is precisely the failure mode the three bounds in #33 exist to avoid. A gate people switch off protects nothing.
The change
The reason now names three outcomes, all ending in marking the file done:
write_episodefor it — check nothing is missing, mark it done, do not write it twiceTesting
13 pass, including a new one pinning outcome 2 in the reason text.