Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[bug] LifeOSHooks prompt.submit context attached after next() is dropped on Claude…

Open IvanLeontev-stack opened this issue 1 month ago • 2 comments

What happened

LifeOSHooks prompt.submit context attached after next() is dropped on Claude Code 2.1.316; after /clear the module keeps the old session id

Summary

LifeOSHooks promptSubmit attaches its composed context after next() resolved, and on Claude Code 2.1.316 the engine drops context attached there. Result: in every armed interactive session the model gets none of the prompt-time context (memory hot layer, AlgorithmNudge, FORMAT CONTRACT, VersionDrift, ModelDriftGuard, presence block, time line), while the prompt-context cap makes the native command hooks fast-exit, so nothing falls back either.

Where: skills/LifeOSHooks/hooks/LifeOSHooks.ts, promptSubmit (current main): const r = await next(input); then const context = [...(r.context ?? []), ...mine]; return { ...r, context };. The FAST-TOGGLE and ORIGIN entries are pushed after next too, so they are dropped the same way.

API (2.1.316 declarations, PromptSubmitResult.context): "A hook attaches context on the way down; one put here after next resolved is not attached (the prompt had entered), and is logged." PromptSubmitInput.context documents the supported form: next({ ...e, context: [...(e.context ?? []), mine] }).

Evidence: a session with caps ["prompt-context", "turn-complete", "band", "voice"] had 40 prompts and zero UserPromptSubmit context attachments in its transcript; HookBridge.ts prompt-context run by hand composes the entries fine, and no prompt-context.failed rows were logged.

Second, related: after /clear the module keeps the old s.sessionId. session.start does not fire for /clear (per the 2.1.316 SessionEndInput doc: "the process goes on under a new session id, and no session.start fires for it"), and the module has no session.end hook, so events, the stamp and the prompt-context cap keep going to the previous session id. The new session is never covered, so the native hooks run instead.

Suggested fix: compose mine (plus FAST-TOGGLE / ORIGIN) before the call and pass it down with next({ ...input, context: [...(input.context ?? []), ...mine] }); re-read $.session.id() at prompt.submit / turn.start (or hook session.end with reason clear / resume) and re-stamp when it changed.

Claude Code 2.1.316, LifeOS 8.761.0, plugin 1.3.0.

Details

  • Kind: bug
  • LifeOS version: 8.761.0

Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.

IvanLeontev-stack avatar Oct 31 '26 14:10 IvanLeontev-stack

Reproduced on Claude Code 2.1.316 with a minimal probe plugin: context passed down as next({ ...e, context: [...(e.context ?? []), mine] }) reaches the model; context appended to the result after next() resolves never does. Still the same on 2.1.318.

Fixed locally by composing everything before next() (the time line, the prompt-context entries, the FAST-TOGGLE and ORIGIN lines) and passing it down in input.context, then running the post-acceptance work (memory acknowledgment, the /f toggle) only after next() returns without a drop. Verified in an interactive 2.1.316 session: the plugin's prompt.submit attachment carries the composed context, and no native MemoryTurnStart row appears.

(Posted by an AI agent on the reporter's behalf, after they read this text.)

nbost130 avatar Nov 05 '26 11:11 nbost130

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks @IvanLeontev-stack, and thanks @nbost130 for the probe that confirmed it. promptSubmit now composes everything first and passes it down in next({ ...input, context }), including the FAST-TOGGLE and ORIGIN lines, and the /fast toggle and memory acknowledgment run only after the prompt entered. The /clear part is fixed too: the module re-reads the session id on each prompt and stamps the new one. This lands in the next release.

danielmiessler avatar Nov 06 '26 13:11 danielmiessler