pi-session-title
Session-title extension for pi-compatible runtimes, including oh-my-pi
Package details
Install pi-session-title from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-session-title- Package
pi-session-title- Version
1.1.0- Published
- Apr 14, 2026
- Downloads
- 44/mo · 14/wk
- Author
- djdembeck
- License
- MIT
- Types
- extension
- Size
- 26.3 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./extensions"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-session-title
Session-title extension for pi-compatible runtimes, including oh-my-pi.
It generates a concise session title from the first real prompt and persists it through the host extension API.
Installation
npm (recommended)
npm install pi-session-title
Manual
git clone https://github.com/djdembeck/pi-session-title.git ~/.omp/agent/extensions/pi-session-title
cd ~/.omp/agent/extensions/pi-session-title
npm install
npm run build
How it works
The extension registers two event handlers:
input— fires in interactive sessions for user-originated inputbefore_agent_start— fires for all prompts before the agent loop. The extension only uses it as a fallback wheninputnever fires (e.g., non-interactive/print mode).
For the first prompt-like input in a session it will:
- Skip extension-originated input and command-style input (
/,!,$) - Skip work when the session already has a name
- Load a prompt template if present
- Use the current session model to generate a title from the first prompt
- Call
setSessionName(title, "auto")— auto-generated titles yield to user-renames (/rename)
In oh-my-pi interactive mode, this timing matters: input handlers run before the built-in first-message auto-title check, so setting the name there prevents omp from generating a competing default title.
Configuration
The extension is configured with environment variables.
| Variable | Default | Description |
|---|---|---|
PI_TITLE_ENABLED |
true |
Enable or disable title generation |
PI_TITLE_TEMPLATE |
unset | Custom template path, relative to cwd or absolute |
PI_TITLE_MAX_INPUT |
2000 |
Maximum characters from the first prompt sent to the model |
PI_TITLE_MAX_TOKENS |
30 |
Maximum tokens requested for the generated title |
Example:
export PI_TITLE_ENABLED=true
export PI_TITLE_MAX_INPUT=1000
export PI_TITLE_MAX_TOKENS=20
Template variables
Available template variables:
{{firstMessage}}{{cwd}}{{timestamp}}
Template discovery
Templates are resolved in this order:
PI_TITLE_TEMPLATE.pi/prompts/title.md.omp/prompts/title.md~/.pi/agent/prompts/title.md~/.omp/agent/prompts/title.md- Built-in default template
Example project template:
Generate a short title (max 6 words) for a coding session.
User request: {{firstMessage}}
Project: {{cwd}}
Respond with ONLY the title.
Compatibility
This package is typed against @mariozechner/pi-coding-agent. At runtime it needs a host that exposes getSessionName() / setSessionName() on the extension API. For title generation via the model, the function attempts to load @oh-my-pi/pi-ai first and falls back to @mariozechner/pi-ai if that import is unavailable. Title generation is only skipped (without error) when neither module is resolvable.
The extension resolves API keys and request headers through both getApiKeyAndHeaders (pi-mono) and getApiKey (oh-my-pi) on the model registry, so it works across both runtime variants.
Development
npm install
npm run typecheck
npm run build
npm test
License
MIT