Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

perf(claude-code): first-message bootstrap asks for mem_context after SessionStart already injected the same context

Open Beginner friendly
#1,687 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, powershell
Domain
tooling

Research direction

Start with plugin/claude-code/scripts/user-prompt-submit.sh:72 and user-prompt-submit.ps1:33, comparing against what session-start.sh:151 injects as additionalContext. Decide which of the two suggested directions to implement (drop the last sentence vs. keep it only when SessionStart injected no context), leaving the ToolSearch instruction untouched. Look for existing tests covering these hook scripts before editing; done means a first-message payload no longer instructs mem_context when SessionStart already provided context, and both Bash and PowerShell versions stay in sync.

Written by the indexing model from the issue text.

Description

status:needs-review type:bug
📋 Pre-flight Checks
  • I have searched existing issues and this is not a duplicate. The closest ones are #163 (size of the SessionStart injection), #581 (slim protocol prose) and #1077 (which tools the first-message ToolSearch loads); none covers the mem_context instruction in the same bootstrap.
  • I understand this issue needs status:approved before a PR can be opened
📝 Bug Description

On the first message of every Claude Code session, the UserPromptSubmit bootstrap tells the agent to call mem_context, although the SessionStart hook has already injected that same project context a moment earlier.

  • plugin/claude-code/scripts/session-start.sh:151 fetches /context?project=…&compact=1&pinned=20&max_bytes=16384 and prints it as additionalContext (lines 207–208), under "Memory from Previous Sessions".
  • plugin/claude-code/scripts/user-prompt-submit.sh:72 (and user-prompt-submit.ps1:33) ends the first-message payload with: After loading tools, call mem_context to check for prior session history before responding.

The agent follows the instruction and receives recent sessions, prompts and observations it already has in context. Line numbers are from main at 1edbd5b.

Measured on Claude Code sessions from Oct 5–6, 2026: mem_context was called in 11 sessions, once each, and in all 11 the SessionStart context was already present. Median response 8.9 KB, 82 KB in total. The cost is one extra tool round trip and a duplicated block per session, not a per-turn cost.

🔄 Steps to Reproduce
  1. Install the Claude Code plugin with engram setup claude-code in a project that has earlier sessions.
  2. Start a new Claude Code session and send any message.
  3. Observe the SessionStart additionalContext with "Memory from Previous Sessions", then the UserPromptSubmit instruction, then a mem_context call whose result repeats those sessions, prompts and observations.
✅ Expected Behavior

When SessionStart has injected the project context, the first-message bootstrap does not ask for mem_context again. The agent still calls it on demand, as the memory skill and the server instructions already describe (start of work, after compaction).

❌ Actual Behavior

Every new session pays one mem_context call that returns content already in context. --protocol=slim does not change this: it gates the protocol prose in session-start.sh and post-compaction.sh, not the UserPromptSubmit payload.

🖥️ Environment
  • OS: Linux (Fedora 44)
  • engram 3.1.0, Claude Code plugin 0.1.6
  • Agent / Client: Claude Code 2.1.292
💡 Additional Context

Possible directions, smallest first:

  • Drop the last sentence from the first-message payload in both the Bash and PowerShell scripts, leaving the ToolSearch part untouched.
  • Or keep it only as a fallback for sessions where SessionStart injected no context (server unreachable, empty project), if the hook can tell.

This is independent of which tools the ToolSearch selector loads (#1077, #1139). Found in the same measurement as #1686.

Dominant language
Go
Stars
7.1k
Forks
729
Avg merge
10h 43m
Merged PRs (30d)
332

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Gentleman-Programming/engram

All issues in Gentleman-Programming/engram

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.