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

未关闭 适合新手
#2,983 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
bun, typescript
领域
ai, backend

调研方向

从 hooks/MemoryTurnStart.hook.ts 开始,重点查看第 62 行的 SOFT_BUDGET_MS 和第 280–288 行的检索 worker 预算。将 300 ms 的预算与报告的 2000 ms 结果进行比较,然后检查该 hook 在不同操作系统上的行为。当检索在报告的条件下不会被跳过,且 prompt 等待时间保持在所选预算内时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
TypeScript
星标
20k
派生
2.5k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

danielmiessler/LifeOS 的其他 Issue

查看 danielmiessler/LifeOS 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。