pi-dent-sticky-model0.1.1
A pi extension that keeps the previous session's model and thinking level across /new
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.
Reports 0
No reports yet.
Readme
pi-dent-sticky-model
A pi extension that keeps the previous session's model and thinking level across /new: instead
of falling back to the startup default, the new session reuses what the previous session last
switched to. defaultProvider/defaultModel are never written. pi-dent bundles it through its
pi.extensions; it also runs standalone in pi.
Published to npm as pi-dent-sticky-model
and listed in the Pi package gallery.
Why
pi.setModel() and pi.setThinkingLevel() record their change in the session's history, and a
new session starts from the configured defaults. An agent that switches models mid-task — a fast
model for the drill, a stronger one for the review — loses that choice on every /new, /clear
followed by more work, or a compaction-heavy session. This extension reads what the previous
session last chose and re-applies it to the new one.
How it works
- Trigger: acts only on a session start with reason
newthat carries a previous session file.startup,reload,resumeandforkare untouched, as is a/newfrom an unpersisted session (no file, nothing to restore). - Reading: the previous session's JSONL transcript is scanned for the last
model_changeentry (provider,modelId) and the lastthinking_level_changeentry (thinkingLevel), each independent of the other. Malformed lines and entries without well-formed fields are skipped; an unreadable file restores nothing and says nothing. - Applying: the model is looked up in the session's model registry and set first; the thinking level is set after it, so the host clamps the level to that model's capabilities. A level without a model entry still applies, to the session's default model.
- Messages: when
setModelreports missing authentication, the extension notifiesNo auth for <provider>/<modelId>with severityerror. An unknown model is skipped silently. - Settings: never written —
defaultProvideranddefaultModelkeep their values, so the startup default still applies wherever no previous session exists.
The exact rules are in specs/sticky-model.md.
Using it
pi-dent bundles it. Standalone:
pi install npm:pi-dent-sticky-model
Requires Node 26 or later. No settings: install and it works.
Development
pnpm check # the done-set: typecheck, lint, fmt:check, test
pnpm test:e2e # end-to-end via pi RPC; needs the pi CLI and provider auth
Every push to main runs the publish workflow: pnpm check, then npm is published via OIDC
trusted publishing; when package.json's version is already on npm, the patch version is bumped
and the bump is committed back to main.