omp packages

pi-sessions-lean0.1.0

Lean Pi version of pi-sessions: search, recall, list, message and cancel sessions through one compact tool.

developer380 Published 5 days ago MIT ~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

pi-sessions-lean

Lean Pi version of pi-sessions by thurstonsand. Search, recall, list, message and cancel Pi sessions through one compact tool instead of six to ten.

Everything keeps working: the same upstream code runs every operation, the session index, automatic titles, /title, /session-index and the Alt+O session reference picker are untouched. Only what the model reads on every request shrinks, and the handoff and subagent features are not exposed.

Upstream keeps its MIT license; see LICENSE, which carries the original copyright.

Install

pi install npm:pi-sessions-lean

Requires Pi 1.5 or newer and Node >=24.

The tool

One tool, sessions, with an op field:

op Does Upstream tool
search find sessions by text, repo, cwd, time or file evidence session_search
recall answer a question from one session's transcript session_recall
list list live sessions you can message session_list
send message a live session session_send_message
cancel cancel a live session's turn session_cancel_turn
help full description and parameters for one op —

Common fields sit in the schema (op, query, session, question, message, report_back, limit). Everything rarer, such as files, repo, time, sort and kind for search, travels through input as a JSON object. op=help with input set to an operation returns that operation's complete upstream description and parameter schema, so nothing is lost — it just is not in the prompt until it is needed.

sessions(op: "search", query: "sqlite index")
sessions(op: "search", query: "db layer", input: "{\"files\":{\"changed\":[\"src/db.ts\"]}}")
sessions(op: "recall", session: "<uuid>", question: "why was the broker made a separate process?")
sessions(op: "help", input: "search")

What the model no longer sees

  • session_handoff and subagent_launch, plus subagent_list, subagent_send, subagent_cancel and submit_task_report. These are captured at load and never registered, so the handoff and subagent settings have no model-facing effect. /handoff is dropped for the same reason.
  • Per-field prose that repeated what the field name and type already said.

Token cost

Measured with npm run measure against Pi 1.7.0, using the fixed ceil(characters / 4) proxy over what the model actually receives: tool name, description, parameter schema, prompt snippet and prompt guidelines.

Scenario Upstream Lean Saved
No worker backend (6 tools) 1200 225 81%
tmux or herdr available (10 tools) 2057 225 89%

The lean surface does not depend on the environment, so the tool list is identical on every machine. Upstream adds or removes session_handoff, subagent_launch and submit_task_report per session start; those calls are inert here, so the list never changes mid-session.

Per-part breakdown of the single lean tool: description 67 characters, schema 518, prompt snippet 47, prompt guidelines 268. One field carries a description (session, because tool output calls it session_id); the rest are plain names and types.

What still behaves like upstream

  • Every operation calls upstream's own execute, with the live extension context, signal and progress callback, so results, errors and provider-facing output are unchanged.
  • Custom TUI rendering is delegated to upstream's renderers for whichever operation the call names.
  • Recall keeps its nested agent, budget and model resolution; search keeps its index, ranking and evidence; messaging keeps its broker and wake behaviour.
  • Settings under sessions in ~/.pi/agent/settings.json still apply, including search.enable: false, which makes op=search report that the feature is off rather than pretending it exists.

Repairs the facade makes

Only shapes that cannot be meant two ways:

  • An omitted op is filled in when the fields name exactly one operation (question → recall, message → send, query → search). session alone stays unresolved, since recall, send and cancel all take one, so validation reports the missing op.
  • session_id copied from tool output is folded into session, unless session is already set.
  • An input object is accepted and forwarded as a JSON string.

Anything ambiguous fails validation with a message naming the operation and the bad field.

Development

npm install
npm test        # fake-host units, real-package integration, scripted agent turns
npm run typecheck
npm run measure # token comparison, --json for machine output

tests/agent-session-worker.mjs and tests/real-session-worker.mjs boot real Pi sessions in child processes, because upstream binds background timers on session start.

See MAINTENANCE.md before upgrading pi-sessions.