omp packages

@rakshazi/session-title0.1.0

Name a session from its first real prompt

rakshazi Published 4 days ago LGPL-3.0-or-later ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

session-title: name a session from its first real prompt

Install with pi install npm:@rakshazi/session-title.

When a TUI session has no name, the first prompt that starts a run is sent to a small model with one question: give this a title. The answer becomes the session name. A greeting or an empty ask gets no title, and the next prompt tries again.

A name that already exists is never touched: one you set with /name, one another extension set, one a fork inherited.

Configuration

In ~/.pi/agent/settings.json:

"sessionTitle": {
  "model": "llama-swap/lfm3-1.7b",
  "grammar": true
}
Key Meaning
model provider/model-id from the model registry. Required.
grammar Send a llama.cpp GBNF grammar with the request, so the reply can only be <title>...</title>. Leave it off for a server that rejects unknown body fields.

Without the section the extension does nothing. The file is read on every request, so an edit applies to the next prompt. The grammar travels in the request body; the llama-swap role stays as it is for every other caller.

What the title model sees

The system prompt is TITLE_SYSTEM.md, read on every request. The user message is built from the prompt after Pi expanded it:

Typed Sent
fix the retry queue <user>fix the retry queue</user>
/skill:plan add a --json flag <skill name="plan">first sentence of the skill's description</skill> then <user>add a --json flag</user>
/skill:pg-backup-rotate the <skill> block alone

The skill body never goes to the title model. The prompt is cut at 4000 characters, the description at its first sentence.

What becomes a name

parseTitle in title.ts takes the text after <title> and rejects a reply with no tag, none in any form, a single word, or braces and angle brackets. A title over 60 characters ends at a word with an ellipsis. A rejected reply, a timeout (30 s) or a model error leaves the session unnamed; an error is shown once per session.

Limits

  • TUI sessions only. Print, JSON and RPC runs, and subagent sessions, never request a title.
  • One title per session. There is no retitle when the topic moves; /name sets a new one by hand.
  • Without grammar, the 1.7B derails on about four prompts in ten, and each of those waits for the next prompt.

Tests

cd ~/.pi/agent/extensions/session-title && node --test title.test.ts