pi-session-router
Pi extension that uses an LLM to route new prompts into the most relevant existing session before continuing
Package details
Install pi-session-router from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-session-router- Package
pi-session-router- Version
0.1.2- Published
- Apr 30, 2026
- Downloads
- not available
- Author
- cloveland
- License
- MIT
- Types
- extension
- Size
- 20.8 KB
- Dependencies
- 0 dependencies · 2 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-router
Pi extension that automatically decides whether a new prompt belongs in another existing session.
Behavior
- intercepts a newly submitted user prompt
- gathers recent project sessions
- asks an LLM to choose the most relevant existing session, if any
- switches to that session before continuing
- if no better session exists, keeps the current one
Commands
/session-router on
/session-router off
/session-router toggle
/session-router status
/session-router threshold 0.80
/session-router notices off
Notes
- this is an opinionated workflow extension
- it uses an unsupported internal
AgentSessionhook to switch sessions invisibly during prompt interception - it can stay in the current session, switch to another local session, or start a new session when no good match exists
- it keeps a lightweight cache at
~/.pi/agent/session-router-cache.json - routing heuristics now use exact informative-token overlap instead of loose substring matching, which avoids false
CURRENTdecisions on unrelated prompts
Local test
pi -e ./pi-packages/pi-session-router
Logic tests
cd pi-packages/pi-session-router
node --test tests/router-logic.test.mjs
Install from local path
pi install ./pi-packages/pi-session-router