MemoryTurnStart: the 300 ms budget skipped memory retrieval on 1 in 4 prompts on a Windows install

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

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bun, typescript
Ambito
ai, backend

Direzione di ricerca

Inizia da hooks/MemoryTurnStart.hook.ts, in particolare da SOFT_BUDGET_MS alla riga 62 e dal budget del worker di recupero alle righe 280–288. Confronta il budget di 300 ms con i risultati segnalati di 2000 ms, poi verifica come si comporta l’hook nei diversi sistemi operativi. Il lavoro è completato quando il recupero non viene saltato nelle condizioni segnalate e l’attesa del prompt rimane entro il budget scelto.

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

Descrizione

Version

LifeOS 8.761.0 · attestation: not run

What is broken

MemoryTurnStart gives per-prompt memory retrieval SOFT_BUDGET_MS = 300 (cut from 4000 on 2026-10-16). When the worker has not answered inside the budget, the prompt gets the notice "retrieval skipped this turn: ... the machine is loaded" and no recalled notes.

On one Windows 11 install the notice replaced retrieval on 19 of 76 prompts (25%) while the release value was in force (2026-11-24 10:45 to 2026-11-26 07:30 UTC), with the hook's wall time at a median of 769 ms. With the budget raised to 2000 ms, 0 of 21 prompts skipped (2026-11-26 07:30 to 2026-11-27 00:00 UTC). Not measured on macOS, so whether this is Windows-only is open.

Where (file:line)

hooks/MemoryTurnStart.hook.ts:62 (SOFT_BUDGET_MS), :280-288 (budget applied to the retrieval worker)

Repro on a clean tree
# Windows 11, 8.761.0 release, Git Bash. Use Claude Code normally for a day or two, then run this from
# ~/.claude. It reads only the UserPromptSubmit hook attachments Claude Code stores in projects/*.jsonl
# and prints counts, no text. Set the first window to when SOFT_BUDGET_MS was 300 on your install;
# here 300 ms ran 2026-11-24 10:45Z to 2026-11-26 07:30Z, and 2000 ms from then to 2026-11-27 00:00Z.
cat > probe.js <<'EOF'
const { readdirSync, readFileSync, statSync } = await import("node:fs");
const { join } = await import("node:path");
const W300 = [Date.parse("2026-11-24T10:45:00Z"), Date.parse("2026-11-26T07:30:00Z")], W2000 = [W300[1], Date.parse("2026-11-27T00:00:00Z")];
const files = [];
const walk = (d) => { for (const n of readdirSync(d)) { const p = join(d, n), s = statSync(p); if (s.isDirectory()) walk(p); else if (n.endsWith(".jsonl") && s.mtimeMs >= W300[0]) files.push(p); } };
walk(join(process.cwd(), "projects"));
const seen = new Set(), b = { 300: { n: 0, skip: 0, ms: [] }, 2000: { n: 0, skip: 0, ms: [] } };
for (const f of files) for (const line of readFileSync(f, "utf8").split(String.fromCharCode(10))) {
  if (!line.includes("UserPromptSubmit")) continue;
  let o; try { o = JSON.parse(line); } catch { continue; }
  const a = o.attachment; if (o.type !== "attachment" || !a || a.hookEvent !== "UserPromptSubmit" || a.type !== "hook_success") continue;
  const out = String(a.stdout || ""); if (!/<lifeos-(memory-delta|ground|memory)>/.test(out) || seen.has(o.uuid)) continue; seen.add(o.uuid);
  const t = Date.parse(o.timestamp), k = t >= W300[0] && t < W300[1] ? 300 : t >= W2000[0] && t < W2000[1] ? 2000 : 0; if (!k) continue;
  b[k].n++; if (typeof a.durationMs === "number") b[k].ms.push(a.durationMs); if (out.includes("retrieval skipped this turn")) b[k].skip++;
}
const med = (x) => x.length ? x.slice().sort((p, q) => p - q)[Math.floor((x.length - 1) / 2)] : null;
for (const k of [300, 2000]) console.log("SOFT_BUDGET_MS " + k + ": " + b[k].skip + " of " + b[k].n + " prompts skipped retrieval; hook wall time median " + med(b[k].ms) + " ms");
process.exit(b[300].skip > 0 ? 1 : 0);
EOF
bun -e "$(cat probe.js)"   # exit 1 when any prompt skipped retrieval at 300 ms
# The notice the model receives on a skipped prompt:
#   <lifeos-ground> (retrieval skipped this turn: the prompt hooks were already past their time budget ...)
Negative control

Probe: bun -e 'const { readdirSync, readFileSync, statSync } = await import("node:fs"); const { join } = await import("node:path"); const W300 = [Date.parse("2026-11-24T10:45:00Z"), Date.parse("2026-11-26T07:30:00Z")], W2000 = [W300[1], Date.parse("2026-11-27T00:00:00Z")]; const files = []; const walk = (d) => { for (const n of readdirSync(d)) { const p = join(d, n), s = statSync(p); if (s.isDirectory()) walk(p); else if (n.endsWith(".jsonl") && s.mtimeMs >= W300[0]) files.push(p); } }; walk(join(process.cwd(), "projects")); const seen = new Set(), b = { 300: { n: 0, skip: 0, ms: [] }, 2000: { n: 0, skip: 0, ms: [] } }; for (const f of files) for (const line of readFileSync(f, "utf8").split(String.fromCharCode(10))) { if (!line.includes("UserPromptSubmit")) continue; let o; try { o = JSON.parse(line); } catch { continue; } const a = o.attachment; if (o.type !== "attachment" || !a || a.hookEvent !== "UserPromptSubmit" || a.type !== "hook_success") continue; const out = String(a.stdout || ""); if (!/<lifeos-(memory-delta|ground|memory)>/.test(out) || seen.has(o.uuid)) continue; seen.add(o.uuid); const t = Date.parse(o.timestamp), k = t >= W300[0] && t < W300[1] ? 300 : t >= W2000[0] && t < W2000[1] ? 2000 : 0; if (!k) continue; b[k].n++; if (typeof a.durationMs === "number") b[k].ms.push(a.durationMs); if (out.includes("retrieval skipped this turn")) b[k].skip++; } const med = (x) => x.length ? x.slice().sort((p, q) => p - q)[Math.floor((x.length - 1) / 2)] : null; for (const k of [300, 2000]) console.log("SOFT_BUDGET_MS " + k + ": " + b[k].skip + " of " + b[k].n + " prompts skipped retrieval; hook wall time median " + med(b[k].ms) + " ms"); process.exit(b[300].skip > 0 ? 1 : 0);' · exit 1 · captured 2026-11-27T01:33:50.840Z

Red looks like: SOFT_BUDGET_MS 300: 19 of 76 prompts skipped retrieval

SOFT_BUDGET_MS 300: 19 of 76 prompts skipped retrieval; hook wall time median 769 ms
SOFT_BUDGET_MS 2000: 0 of 21 prompts skipped retrieval; hook wall time median 583 ms
Suggested fix

Applied on one install: SOFT_BUDGET_MS 300 -> 2000 (MemoryTurnStart.hook.ts:62). Skips went from 19 of 76 prompts to 0 of 21 over the windows in the probe. Cost: a prompt sent while retrieval is slow can wait up to 2 s for its notes; the hook still returns as soon as the worker answers.

A narrower option, not tried: keep 300 ms on macOS and use a larger budget on win32, or make the budget a setting.

Environment
  • OS: Windows (x64)
  • Harness: claude-code
  • bun: 1.4.2 · git: 2.56.1.
  • Doctor broken: none
Lingua principale
TypeScript
Stelle
20k
Fork
2.5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 danielmiessler/LifeOS

Tutte le issue di danielmiessler/LifeOS

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.