feat(plugin/claude-code): mandate mem_context at session start to prevent blind sessions#138
Open
franbaigorria wants to merge 1 commit intoGentleman-Programming:mainfrom
Conversation
…vent blind sessions Add SESSION START section to SKILL.md making mem_context unconditionally mandatory as the first action of every session, before responding to the user. Removes conditionality that caused agents to skip context loading when the first message seemed unrelated to prior work.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #137
🏷️ PR Type
type:feature— New feature📝 Summary
## SESSION START (mandatory)section toplugin/claude-code/skills/memory/SKILL.mdmem_contextunconditionally required as the agent's first action on every session — before responding to any user message📂 Changes
plugin/claude-code/skills/memory/SKILL.mdSESSION START (mandatory)section beforeWHEN TO SEARCH MEMORY🧪 Test Plan
go test ./...go test -tags e2e ./internal/server/...No Go code changed — this is a protocol text change. Verified by starting a new Claude Code session and confirming the agent calls
mem_contextbefore responding to the first message, regardless of its content.💬 Notes for Reviewers
The problem
session-start.shalready fetches context and injects it viaadditionalContext. But the SKILL.md told the agent to search memory only conditionally — when the user's first message "references a project, a feature, or a problem." In practice, sessions often start with something unrelated (a build log, a system error, an unrelated question). The agent reads the message, sees no obvious signal of prior work, and skips loading context entirely.The memory is there. The agent just never looks.
Why this fix over the alternatives
Option A — FTS fallback with individual term matching (
internal/store/store.go): Improves search recall when query terms don't match exactly how the memory was saved. Addresses a symptom, not the root cause. The agent still has to decide to search — if it skips that step, better search doesn't help. Worth pursuing as a follow-up.Option B —
UserPromptSubmithook injection: Adds latency to every first prompt, requires heuristic relevance detection at the shell level, and duplicates whatmem_contextdoes with less flexibility. Adds complexity to the wrong layer.Option C — SKILL.md protocol change (this PR): One call, always, before anything else. No infrastructure change, no risk, immediate behavioral improvement. Fixes the root cause at the right layer: the agent's instructions.
The change