feat(claude-code): configurable SessionStart and post-compaction context byte budget

Aperta Adatta ai principianti
#2,416 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bash, markdown, shell
Ambito
tooling

Direzione di ricerca

Inizia con plugin/claude-code/scripts/session-start.sh intorno alle righe 141-145 e plugin/claude-code/scripts/post-compaction.sh riga 30, dove max_bytes=16384 viene passato all'endpoint del contesto; controlla l'endpoint e mem_context per confermare il limite superiore accettato. Aggiungi una singola lettura di ENGRAM_CONTEXT_MAX_BYTES in entrambi gli hook: valore predefinito 16384 quando non impostata, fallback su valori non positivi/non interi, clamp al limite dell'endpoint e lascia compact=1 e pinned=20 invariati. Esegui i test esistenti di hook/endpoint con un override di 6144 byte e valori non validi, poi documenta la variabile e la sua sopravvivenza attraverso gli aggiornamenti del plugin e gentle-ai sync.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status:needs-review type:feature
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 settings env) is passed as max_bytes; invalid values fall back to the default; values above the endpoint's upper bound are clamped.
  • compact=1 and pinned=20 stay 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).

Lingua principale
Go
Stelle
7.1k
Fork
729
Merge medio
2h 19m
PR unite (30g)
167

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Gentleman-Programming/engram

Tutte le issue di Gentleman-Programming/engram

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.