trim_serve_processes
Close leftover Kiln servers left by closed agent sessions to reclaim memory, keeping active sessions and blocking cleanup while a print is in progress.
Instructions
Close leftover Kiln servers left behind by closed sessions.
Every agent session spawns its own background Kiln server;
client apps don't reliably close them when a session ends, so
they accumulate and quietly hold memory. This is the cleanup
the pile-up warning (health_check / kiln_health / get_started)
offers.
WHY THIS IS SAFE: closing a server never stops a physical
print — the printer keeps going regardless. What a close can
end is MONITORING (a running watch loop). So this refuses to
act while any printer has a job in flight, and otherwise the
worst case is that a still-open session reconnects. This
session's own server is never closed.
AGENT CONTRACT (important):
* ASK THE USER how many agent sessions they actually have
open right now and pass it as open_sessions — they are
the one source of truth for that, and it beats guessing
from process age. Never ask them for a PID.
* Confirm before acting. Called without confirm, this
returns the plan (how many would close, how many stay)
to show the user; pass confirm=True once they agree.
* If it comes back blocked because something is printing,
tell the user what's printing and leave it alone — offer
to clean up after the print finishes rather than
reaching for force.
Args:
confirm: Set True to actually close the leftovers.
open_sessions: The user's own count of agent sessions
currently open. Keeps that many most-recently-started
servers and proposes the rest.
force: Proceed even though a printer has a job in flight.
Only when the user explicitly insists, knowing that
monitoring for that job may stop.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "trim_serve_processes"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Proceed even though a printer has a job in flight. Only when the user explicitly insists, knowing that monitoring for that job may stop. Default: false. | |
| confirm | No | Set True to actually close the leftovers. Default: false. | |
| open_sessions | No | The user's own count of agent sessions currently open. Keeps that many most-recently-started servers and proposes the rest. |