Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

PromptProcessing hook: when naming inference fails, sessions get word-salad names or no name at all, permanently

Open lgertel opened this issue 3 months ago • 2 comments

Version: LifeOS 7.40.4 (ce046f2)

What

The first-prompt namer calls inference with a short timeout. When that call fails (measured on one install: 11 of 48 first prompts over a day hit inference-failed at 3.2–3.7 s), the hook falls back to extractFallbackName, whose first strategy anchors on ALLCAPS tokens as "acronyms/proper nouns" and title-cases the words around them. Real prompts produce names like "Launch ISA CONTROL LEDGER GOAL", "Clean BOTH TWO SPECIFIC READ", "Fix Details Build Missing Missing". When the fallback also fails the validator (last-resort-rejected, 10 of the same 48), the session is left with no name and nothing ever retries, so the statusline, the Work page ("N active sessions") and the menubar feed carry the salad or a blank for the life of the session.

Where

hooks/PromptProcessing.hook.ts

  • extractFallbackName (line 470); Strategy 0 at lines 500–521: contentWords.filter(cw => /^[A-Z]{2,8}$/.test(cw.word)) then parts.slice(0, 5).map(titleCase).join(' ').
  • Inference failure branch, source: 'inference-failed' (line 1138): falls straight to the fallback, no retry.
  • Last resort at lines 1179–1187: isValidSessionName(lastResort) false → console.error("Rejected last-resort name"), session_name: null, source: 'last-resort-rejected'; the session stays unnamed.

Reproduce

  1. Make inference slow or unavailable for the hook (e.g. no network for the model call, or a tight timeout), then open a session with a first prompt containing an ALLCAPS token: "launch the ISA for the CONTROL LEDGER goal".
  2. Read the stored session name (statusline, or the session's entry in the work JSON): "Launch ISA CONTROL LEDGER GOAL".
  3. Repeat with a prompt that has no content words the validator accepts: the name stays null and prompt-processing.jsonl logs last-resort-rejected; no later prompt renames it.

Expected

  • A first prompt is never left nameless.
  • A stored name never contains two or more ALLCAPS tokens; the fallback prefers the first clause in sentence case.
  • A failed inference is retried out of the hook's critical path and the session is renamed in place when the retry succeeds.

Fix shape

The hook returns fast with the best deterministic name, then spawns a detached retry of the inference that, on success, renames through the existing updateSessionNameInWorkJson; the fallback validator rejects ALLCAPS salad and always yields a name. Ten hook tests cover the detached retry end to end. A PR can follow as one hook hunk plus tests.

lgertel avatar Sep 02 '26 03:09 lgertel

Half landed: the validator rejects word-salad (two or more ALLCAPS tokens) and the scraper prefers a sentence-case first clause. The detached retry for a failed naming inference is a bigger change than fits this pass, so "never nameless" is still open here. Next release for what landed. Thanks.

danielmiessler avatar Sep 03 '26 23:09 danielmiessler

This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.

Checked your comment — confirmed the validator half wasn't in our 7.40.4 yet. Patched locally: isValidSessionName() now caps ALLCAPS middle-word tokens at 1 before rejecting (two or more is the word-salad signature itself, e.g. "Launch ISA CONTROL LEDGER GOAL"), while still allowing legitimate single-acronym names ("Fix API Rate Limiting Bug"). Verified by trace against your own repro. Left the detached-retry half alone, matches your note that it's a bigger change deferred separately.

waveman2020-sudo avatar Sep 17 '26 14:09 waveman2020-sudo