You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
agent-device session folders under the worker's data directory are never removed #1411
The agent-device daemons a worker runs leave one folder per session under ~/.simlock/agent-device/sessions, and nothing removes them. #1409 counted 12,556 folders (4.9 GiB) on one worker.
No code in src/agent-device/ names that folder except the route check in src/agent-device/shared/routes.ts:38. A lease end (src/agent-device/host/lease-end.ts:150) sends agent_device.lease.release and deletes nothing on disk. So either agent-device prunes its own sessions, or simlock does at lease end. Which side owns it is open.
Confirmed. A gap: the test's expectation is a proposal (simlock sweeps at lease end).
src/agent-device/session-folders.test.ts, "a lease end removes every agent-device session folder of both daemons that nothing wrote to for longer than the agent-device lease ceiling, and keeps one written since", on bug/1411-repro:
Gap. AgentDeviceLeaseEnd.leaseEnded (src/agent-device/host/lease-end.ts:150) only sends agent_device.lease.release, and no simlock code reads <stateDir>/sessions for either daemon. agent-device 0.21.35 makes one folder per session address (sessions/<lease id> for the allocate, sessions/<tenant>_<session> for commands) and on close removes only its tombstone files, never the folder. Simlock cannot map a folder to its lease: the CLI's --session picks any name. So the only complete fix in simlock is age-based. A session cannot outlive its agent-device lease, and that lease cannot outlive agentDeviceLeaseMaxTtlMs (one day by default), so a folder nothing wrote to for longer than that belongs to no live lease.
Simplest fix
AgentDeviceLeaseEnd takes a SessionSweep (filesystem, clock, <home>/<stem>/sessions, agentDeviceLeaseMaxTtlMs). After each lease end it removes every folder whose newest entry is older than that limit. worker.ts builds one sweep for each daemon. It pins the age rule, no config key.
$ pnpm exec vitest run --project unit src/agent-device/{session-folders,edge-lease-end,edge,dispose}.test.ts src/agent-device/host/lease-end.test.ts
Test Files 5 passed (5) Tests 168 passed (168)
Alternatives rejected
agent-device removes a session's folder on close: another repo, and existing folders stay.
Delete sessions/<leaseId> and sessions/<tenant>_<leaseId> at lease end: misses folders named with --session.
Sweep only at daemon start: a worker that runs 30 h keeps a day of folders.
Risk
The first sweep on a worker with 12k folders stats each one inside a lease end: check leasing's end wait, or run it in the background.
Only the folder and its direct entries are statted, so a write deep in requests/ alone is missed.
The manual needs a "Lease end" line for the sweep.
Simlock's agent-device adapter owns session-folder cleanup, not agent-device upstream. File transfer makes this more pressing: uploaded files keep a session folder large until it is removed.
The maintainer decided (2026-11-07): simlock's agent-device adapter removes session folders. No age sweep.
At each lease end, simlock removes the session folders of that lease in the daemon that served it: sessions/<lease id>, sessions/<tenant>_<lease id>, and sessions/<tenant>_<name> for every --session name a command on that lease carried through the front.
At each daemon start, before agent-device runs, simlock removes every folder under that daemon's sessions/: a restart ends every agent-device lease, so none of them is live. This also clears folders left by earlier versions.
Tests: a lease end removes its own folders, including one named with --session, and keeps another live lease's folder. A daemon start empties sessions/ for both daemons.
Activity
V3RON commentedon Nov 7, 2026
Reproduction
Confirmed. A gap: the test's expectation is a proposal (simlock sweeps at lease end).
src/agent-device/session-folders.test.ts, "a lease end removes every agent-device session folder of both daemons that nothing wrote to for longer than the agent-device lease ceiling, and keeps one written since", onbug/1411-repro:Root cause
Gap.
AgentDeviceLeaseEnd.leaseEnded(src/agent-device/host/lease-end.ts:150) only sendsagent_device.lease.release, and no simlock code reads<stateDir>/sessionsfor either daemon. agent-device 0.21.35 makes one folder per session address (sessions/<lease id>for the allocate,sessions/<tenant>_<session>for commands) and on close removes only its tombstone files, never the folder. Simlock cannot map a folder to its lease: the CLI's--sessionpicks any name. So the only complete fix in simlock is age-based. A session cannot outlive its agent-device lease, and that lease cannot outliveagentDeviceLeaseMaxTtlMs(one day by default), so a folder nothing wrote to for longer than that belongs to no live lease.Simplest fix
AgentDeviceLeaseEndtakes aSessionSweep(filesystem, clock,<home>/<stem>/sessions,agentDeviceLeaseMaxTtlMs). After each lease end it removes every folder whose newest entry is older than that limit.worker.tsbuilds one sweep for each daemon. It pins the age rule, no config key.Alternatives rejected
sessions/<leaseId>andsessions/<tenant>_<leaseId>at lease end: misses folders named with--session.Risk
requests/alone is missed.Fast track
Written by an agent.
V3RON commentedon Nov 7, 2026
Maintainer decision
Simlock's agent-device adapter owns session-folder cleanup, not agent-device upstream. File transfer makes this more pressing: uploaded files keep a session folder large until it is removed.
Written by an agent.
V3RON commentedon Nov 7, 2026
The maintainer decided (2026-11-07): simlock's agent-device adapter removes session folders. No age sweep.
sessions/<lease id>,sessions/<tenant>_<lease id>, andsessions/<tenant>_<name>for every--sessionname a command on that lease carried through the front.sessions/: a restart ends every agent-device lease, so none of them is live. This also clears folders left by earlier versions.--session, and keeps another live lease's folder. A daemon start emptiessessions/for both daemons.Written by an agent.
test: a daemon start empties sessions/ for both daemons (#1411)
fix(agent-device): a daemon start empties its sessions folder (#1411)
fix(agent-device): mark the folder-name reader as used by the partici…
fix(agent-device): a lease end finds the folder of a --session name a…
docs(agent-device): name the sessions folder without a path the manua…
test(agent-device): the escape assertion goes red when a lease end le…
V3RON commentedon Nov 7, 2026
Delivery run
Merged: #1413 (#1411)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(agent-device): session folders are removed at lease end and at da…