Skip to content

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

Description

@lgertel

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions