Repository navigation
Conversation
A client that stops reading let its event queue grow without limit: one 24 MB command with an unread stream buffered 22.7 MB on the server. Cap the queued bytes per client (PI_WEB_SSE_BACKLOG_LIMIT_BYTES, default 4 MB). Past the cap, drop events the client can rebuild from session state, and close the stream for backlog that cannot be rebuilt so the client reconnects and re-snapshots instead of holding memory.
Per-device switch (Settings -> General -> Session lifetime) with three effects:
- Session lifetime. A page holds a per-tab presence for the session it shows and
releases it on a conversation switch, on page close, or after an idle window
without real interaction. Hiding the page keeps the session warm, another tab
or device viewing it blocks the close, and a running task is never interrupted.
- Model settings. Lite requests read the built-in catalogue plus models.json
through ModelRuntime.create() instead of loading every configured extension.
enabledModels writes still use the full catalogue, and a session pinned to an
extension model is flagged, never switched.
- Soft memory target. Configurable, measured read-only from the cgroup, acted on
by reclaiming the oldest idle, unviewed sessions when usage is near or over it.
Nothing is killed and systemd is untouched. The target exists only in Lite
mode; normal mode reports { active: false } and keeps its current behaviour.
The settings control read the memory status once at mount while the chat notice polled, so the two drifted. Both now read one shared store with a single in-flight-deduped refresh and one 10 s poll loop; saving a target broadcasts to every subscriber before the reconcile request returns. The idle window becomes a device-local option (1-60 minutes, default 5, synced across tabs of the same browser), the settings copy is shortened, the memory target is hidden and inert while Lite mode is off, and its default moves to 1800 MiB — a starting point for a fresh install, not a tuned value.
isRunning() only described a wrapper's own turn, so a session whose async subagent was still working looked idle: reclaim, the pressure pass and the 10-minute idle shutdown could close it and kill an in-process child with it. /api/agent/running had the same hole. isBusy() now means "own turn or delegated work", decided from two read-only signals: recent writes under <session file without .jsonl>/ (where any child run writes its own session) and the pi-subagents run registry when readable. Unreadable state counts as busy, and a deferred close is retried every 30 s.
HoloNova
marked this pull request as draft
September 29, 2026 23:14
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an opt-in Lite mode (Settings → General → Session lifetime) and fixes a
way sessions could be closed out from under a running child. Normal mode is
unchanged: nothing here runs unless the user turns Lite mode on.
and releases it on a conversation switch, on page close, or after the idle
window (device-local, 1–60 minutes, default 5) without real interaction —
typing, clicking, touching, scrolling. Heartbeats, polling and SSE do not
count. Hiding the page (tab switch, minimized window, another app) keeps the
session warm. Presence is per (session, tab), so one tab cannot close a session
another tab or device is still viewing, and a running task is never
interrupted.
provider routes use
ModelRuntime.create()— built-in providers plusmodels.json— instead of loading every configured extension to answer aprovider list.
enabledModelswrites still compute from the full catalogue, soa Lite save cannot prune extension-provided entries, and a session pinned to an
extension model is flagged, never silently switched.
read-only from the service's own cgroup, and acted on by reclaiming the oldest
idle, unviewed sessions when usage is near (≥ 90 %) or over it. Soft by
construction: no process is killed and systemd is untouched. The target exists
only in Lite mode — a normal-mode
GET /api/memoryreports{ active: false }and
PUTis refused — so normal mode has no ceiling.isRunning()only described a wrapper's ownturn, so an async subagent run that outlived its parent turn looked idle and
could be closed, killing in-process children with it.
isBusy()now coversboth, decided from two read-only signals: recent writes under
<session file without .jsonl>/(where every child run writes its own session,whichever plugin spawned it) and the pi-subagents run registry when readable.
Unreadable state counts as busy, and a deferred close is retried every 30 s.
/api/agent/runninguses the same predicate, so anything that waits for aquiet service — a nightly restart guard, for instance — no longer skips a busy
host by luck.
Verified
node --experimental-strip-types --testfor the new suites (Lite lifecycle,memory status store, reclaim planner, delegated-work detection) plus the
existing Lite/model/settings/i18n suites;
tsc --noEmitandeslintclean.Also deployed and exercised on a 2 vCPU / 3.8 GB VPS host: three Lite provider
reads no longer spawn extension hosts (6 → 6 helper processes, versus +1 for a
single non-Lite read), and an idle session releases about five minutes after the
last interaction, closing the wrapper and reopening it in under a second on
return.
Not done on purpose
EventSourcecannotcarry the Lite header, and login is a one-off interaction.
enabledModelswrite still loads extensions once, for thefull-catalogue guard above.
evictIfDiskAhead(the explicit "reload session from disk" action) isuntouched: it is user-initiated, not an automatic reclaim.