feat(claude-code): configurable SessionStart and post-compaction context byte budget
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
Start with plugin/claude-code/scripts/session-start.sh around lines 141-145 and plugin/claude-code/scripts/post-compaction.sh line 30, where max_bytes=16384 is passed to the context endpoint; check the endpoint and mem_context to confirm the accepted upper bound. Add a single ENGRAM_CONTEXT_MAX_BYTES read in both hooks: default to 16384 when unset, fall back on non-positive/non-integer values, clamp at the endpoint limit, and leave compact=1 and pinned=20 untouched. Run the existing hook/endpoint tests with a 6144-byte override and invalid values, then document the variable and its survival across plugin upgrades and gentle-ai sync.
Written by the indexing model from the issue text.
Description
Existing Issue Search
- I searched existing issues and will add evidence to a canonical tracker when applicable.
No existing tracker for the Claude Code hook context budget (searched max_bytes, context budget). Related but distinct: #1373 (Pi mem_context options, closed), #1075 (mem_context budget follow-ups, closed).
🔍 Observed Consequence
Both Claude Code hooks request a literal max_bytes=16384 from the context endpoint, so every session start and every compaction injects up to 16 KiB of memory context, and users cannot lower it:
The endpoint and mem_context already accept per-call byte budgets, but the hooks expose no override. Editing the installed plugin scripts is overwritten by plugin updates and gentle-ai sync.
💡 Desired Outcome
One documented environment override honored by both hooks (suggested name: ENGRAM_CONTEXT_MAX_BYTES):
- Unset keeps today's default of 16384.
- A valid positive integer (e.g.
6144, set through Claude Code's settingsenv) is passed asmax_bytes; invalid values fall back to the default; values above the endpoint's upper bound are clamped. compact=1andpinned=20stay unchanged.- Docs state that it bounds the context field only, not the protocol or hook wrapper text, and how it survives plugin upgrades and
gentle-ai sync.
Acceptance: both hooks honor a valid override and keep the default when unset; tests cover a 6144-byte override, invalid values, the upper bound, and UTF-8-safe truncation through the existing endpoint. Proactive saves, conflict judgments, passive capture and tools are unaffected.
📦 Affected Area
Other
Release Context
engram v3.7.2 (Claude Code plugin hooks), managed by gentle-ai v4.6.0
🔄 Workarounds and Constraints
None that survive updates; patching the plugin scripts is overwritten.
📎 Additional Context
Related, not requested here: ENGRAM_NUDGE_COOLDOWN_SECS already debounces repeat save reminders, but the first reminder's 15-minute threshold and wording are hard-coded (user-prompt-submit.sh#L554-L565).
- Dominant language
- Go
- Stars
- 7.1k
- Forks
- 729
- Avg merge
- 1h 35m
- Merged PRs (30d)
- 154
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Gentleman-Programming/engram
-
status:needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Gentleman-Programming/engram#2515 ·
Maintainers usually reply within 1 day
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Gentleman-Programming/engram#2512 ·
Maintainers usually reply within 1 day
-
status:needs-review
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Gentleman-Programming/engram#2502 ·
Maintainers usually reply within 1 day
-
status:needs-review type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Gentleman-Programming/engram#2501 ·
Maintainers usually reply within 1 day
-
feat(claude): explicit cross-project memory saves from a Claude Code session (parity with Pi #1591)Openstatus:needs-review type:feature
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Gentleman-Programming/engram#2514 ·
Maintainers usually reply within 1 day
All issues in Gentleman-Programming/engram
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
erigontech/erigon#27233 ·
Maintainers usually reply within 1 day
-
area/tests needs-triage theme/ci-dx
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
kubescape/kubescape#6095 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
oras-project/oras-go#1853 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100