Repository navigation
feat: clients show when the host is short on memory and which agents use the most - #27253
juliusmarminge wants to merge 6 commits into
Conversation
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — Web and mobile now enable memory-pressure reporting by default and show severe-pressure warnings with agent Force stop controls. Human review is required for this product-default change; stopping agents remains user-initiated and permission gated. Needs human approval because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
8629be9 to
23ae0c9
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
23ae0c9 to
457a354
Compare
Dismissing prior approval to re-evaluate 457a354
457a354 to
fa6846c
Compare
fa6846c to
85a03db
Compare
85a03db to
fea4242
Compare
fea4242 to
e7c4157
Compare
e7c4157 to
37591d0
Compare
2842f17 to
c8fcb29
Compare
|
Effect Service Conventions: GitHub attached only two of the four submitted inline comments. The findings are:
These fixes span imports/usages or multiple error declarations and consumers, so no self-contained suggestion is included. Posted via Macroscope — Effect Service Conventions |
7812a34 to
c2ee4be
Compare
|
Adversarial review follow-up (c2ee4be):
🤖 Generated with Claude Code |
c2ee4be to
0f74dca
Compare
…use the most Agents starved of memory freeze silently: in the incident the kernel throttled the agents slice for hours and nothing told the user why every turn hung. The server now reads memory pressure (Linux PSI for the host and the agents slice, macOS's pressure level) and derives none/elevated/severe with hysteresis. Clients that opt in get it on the config stream. While pressure is severe, web shows a sidebar warning and mobile a banner on the thread list, both naming the heaviest agents with links to their threads and Force stop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
0f74dca to
906b4c4
Compare
|
A measured case of the problem this PR describes, from a Debian 13 LXC host (22 GiB RAM, t3 0.1.6, I proposed a follow-up on #23718 that uses this PR's pressure level: hold agent-started runs as Written by Claude Opus 5.5 in Claude Code on behalf of @OmarAlex24. |
|
This would be useful. It's the visibility half of a problem several people have hit: too many parallel threads or runs overloading one host (#27530, #32205). Would you be open to a follow-up that uses the same signal to prevent overload, not only report it?
That covers composer threads, scheduled tasks and |
… the branch stack Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2-memory-pressure # Conflicts: # apps/mobile/src/connection/runtime.ts # apps/mobile/src/features/home/HomeScreen.tsx # apps/server/src/resourceTelemetry/HostResources.test.ts # apps/server/src/resourceTelemetry/HostResources.ts # packages/client-runtime/src/rpc/session.test.ts # packages/client-runtime/src/state/server.ts
HostResourcesSnapshot.memoryPressure had no reader, and sampling it from read advanced the stream's hysteresis and unread-sample count from a second path. The reconnect projection now reads capabilities only when pressure is held, so partial snapshots in tests still project. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main replaced the crypto service in NativeTelemetryClient; match the sibling commands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| return Option.flatMap(current, (projection) => { | ||
| const { memoryPressure: _previous, ...config } = projection.config; | ||
| // Keeps config identity, so screens reading it do not re-render. | ||
| if (event.payload.level === "none" && projection.config.memoryPressure === undefined) |
There was a problem hiding this comment.
🟡 Medium state/serverConfigProjection.ts:195
When a none event arrives while this session projection has no memoryPressure, this branch returns Option.none(), so the authoritative calm reading is never recorded as latestEvent or broadcast; reconnects can therefore retain a carried severe warning indefinitely. Return the projection with latestEvent: event while preserving projection.config identity in this case.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/client-runtime/src/state/serverConfigProjection.ts around line 195:
When a `none` event arrives while this session projection has no `memoryPressure`, this branch returns `Option.none()`, so the authoritative calm reading is never recorded as `latestEvent` or broadcast; reconnects can therefore retain a carried severe warning indefinitely. Return the projection with `latestEvent: event` while preserving `projection.config` identity in this case.
| const v2ListHeader = ( | ||
| <> | ||
| {listHeader} | ||
| <MemoryPressureBanner /> |
There was a problem hiding this comment.
🟡 Medium home/HomeScreen.tsx:680
On Android, when the current filters produce no rows, the severe-memory warning and Force stop controls disappear because the early return renders only v2ListEmpty and bypasses v2ListHeader, where MemoryPressureBanner is mounted. Render the banner in that empty-state path as well, or in a shared container outside the list, so pressure from agents outside the selected filter remains actionable.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/mobile/src/features/home/HomeScreen.tsx around line 680:
On Android, when the current filters produce no rows, the severe-memory warning and Force stop controls disappear because the early return renders only `v2ListEmpty` and bypasses `v2ListHeader`, where `MemoryPressureBanner` is mounted. Render the banner in that empty-state path as well, or in a shared container outside the list, so pressure from agents outside the selected filter remains actionable.
A fresh session holds no pressure, so its projection dropped the server's none event before the session recorded and replayed it. A client still holding severe from before the reconnect then kept the warning. Keep the same projection instead, so the session replays none while config identity, and so rendering, is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for this. Main has the change since #44713. Main now provides the memory-pressure warnings, heaviest-agent thread links and Force stop controls on web and mobile that this PR adds. Compared its commits and changed files against the merge's Linux PSI and macOS sampling, hysteresis, opt-in config stream, reconnect clearing and client warnings; these behaviors are covered by the broader host-pressure implementation. Closing as superseded. |
Upstream's pingdotgg#44713 supersedes the pingdotgg#27253 port, so its commit is dropped and host admission reads upstream's HostPressure: the memory level gates admission as before. The admission test's projection store gets a Digest, a carried admission state is read only when one is held, and the Cursor runner test's controlGroups key, now set upstream, is no longer added twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…host capacity Say which branches on origin make up the fork and that every other branch is a short-lived work branch the run only reports. The update runs once a week on Sundays at 20:00, not twice a day. feat/host-capacity no longer ports pingdotgg#27253 (closed upstream; pingdotgg#44713 and pingdotgg#44714 ship the warnings), so drop the instructions that tracked it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
When the agents slice is throttled for memory, every agent freezes and nothing in T3 says why. Turns just keep saying Working.
Fix
HostResources) reads memory pressure:/proc/pressure/memoryfor the host, plus the agents slice'smemory.pressure, located through the newAgentScope.controlGroups.kern.memorystatus_vm_pressure_level, read by the already-running native resource monitor throughsysctlbyname. Sampling never spawns a process: under memory pressure a new process may fail to start, which is exactly when the reading matters. The sidecar answers a newmemoryPressurecommand; releases build and bundle it from the same commit as the server.none / elevated / severe, with hysteresis: a level is entered above its threshold and left only well below it, so it does not flicker.full≥ 2 %, hostsome≥ 10 %, or agentsfull≥ 5 %.full≥ 10 %, agentsfull≥ 20 %, or macOS critical.none, the top three agent scopes bymemory.currentare included with their thread (shared processes appear as e.g.codex (shared)). Sizes are rounded to about 1/8 of their magnitude so normal growth doesn't push an update every sample.HostResourcesSnapshotgains an optionalmemoryPressure.memoryPressure: true(capabilitymemoryPressure) getmemoryPressureUpdatedon the config stream, mirroring howusageLimitSourceswas added so older clients never see an unknown event type.Stream.shared 5 s poll that runs only while someone listens, and emits only on change.noneupdate that changes nothing leaves the client's config untouched, so nothing re-renders.none, so a warning cannot outlive the pressure.Verification
AgentScope.controlGroupsmaps scopes to threads in the fake-systemd harness.noneupdate when nothing is stored.HostResourcestakes the level from the sidecar; the test's spawner fails if sampling spawns anything (it did before).memoryPressurereturned level 1 from the real syscall, and on Linux, where it returnsnull.vp run check:changedpasses for the stack.Evidence (web)
No load was generated on nucbox-1. For the capture only, an uncommitted two-line patch pointed the PSI reads at a fixture file holding severe readings (host
full avg10=6.4, agentsfull avg10=84.7). The agents, their scopes andmemory.current, the stream, and the UI are all real.Limits
Model: Claude Opus 5.5, harness: Claude Code (in T3 Code).
🤖 Generated with Claude Code