Skip to main content
Glama

gograph_session_cleanup

DestructiveIdempotent

Archive stale session telemetry without deleting it: end idle or exited-server sessions, preserve the active log, and move eligible logs into a timestamped cleanup folder.

Instructions

Archive stale and inactive session telemetry without following linked repository paths; never deletes. Each pass moves files into .gograph/to_delete//. First ends other callers' CLI-owned sessions idle past the idle limit (GOGRAPH_SESSION_IDLE_LIMIT, default 2h) or MCP-owned sessions whose server process exited on this host (owners without metadata or on another host are kept), listing each, and archives an unselected legacy active_session.json; then archives logs with end records; preserves the selected active log and refuses while any other caller is still live. MCP annotations mark this operation mutating and destructive. No prerequisites. WHEN TO USE: Call after auditing to keep the repository clean. RETURNS: Each ended session, any archived legacy pointer, and the number of session logs moved with the archive folder, or Nothing to archive.

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": "gograph_session_cleanup"
  }
}

Input Schema

NameRequiredDescriptionDefault
rootNoAbsolute path of your checkout or worktree (alias cwd).
intentionNoRationale; required with an active session.
session_idNoSession from session_create; omit for none.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.7.21
    • changedInput schema / properties / intention / description
      Previous value: -"Technical rationale, required for analytical calls selecting an active session."New value: +"Rationale; required with an active session."
    • changedInput schema / properties / root / description
      Previous value: -"Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean."New value: +"Absolute path of your checkout or worktree (alias cwd)."
    • changedInput schema / properties / session_id / description
      Previous value: -"Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session."New value: +"Session from session_create; omit for none."
  2. Changed3 schema fields changedv1.7.18
    • addedInput schema / properties / intention
      Added value: +{
      +  "description": "Technical rationale, required for analytical calls selecting an active session.",
      +  "type": "string"
      +}
    • addedInput schema / properties / root
      Added value: +{
      +  "description": "Absolute path of the checkout you are working in (your cwd or git worktree). Must be this server's repository or one of its git worktrees; the answer then comes from that checkout's own graph. A path elsewhere is refused. Alias: cwd. Omit only when the configured checkout is the one you mean.",
      +  "type": "string"
      +}
    • addedInput schema / properties / session_id
      Added value: +{
      +  "description": "Caller selector returned by session_create. Omission means an independent caller; never inherits server environment or another caller's session.",
      +  "type": "string"
      +}
  3. Added

TDQS

A4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations: discloses the archive destination path pattern, what qualifies for ending (idle past GOGRAPH_SESSION_IDLE_LIMIT default 2h, MCP-owned sessions whose server process exited on this host), and explicitly what is preserved (owners without metadata or on another host, the selected active log). It also discloses the refusal condition and that the legacy active_session.json pointer is archived rather than removed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Led by the crucial constraint ('without following linked repository paths; never deletes'), which is well front-loaded, but the middle becomes a single sprawling sentence combining idle-limit rules, host-ownership rules, pointer archiving, and log archiving. The WHEN TO USE / RETURNS labels help, yet the operational detail is hard to parse and could be split or bulleted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, multi-phase maintenance operation with no output schema, the description covers the necessary ground: phases, preservation rules, refusal behavior, the env-var threshold, and an explicit RETURNS section including the 'Nothing to archive' case. Minor gaps remain, such as what the <suffix> in the archive folder name is and any default for root.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so root, intention, and session_id are already documented in the input schema, and the baseline of 3 applies. The description alludes to the 'selected active log' and 'selected active_session.json' (relevant to session_id) and cites the idle-limit env var, but adds no new meaning about root or intention beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: archives stale/inactive session telemetry, with the key qualifier that it never deletes (files are moved to a .gograph/_to_delete/<time>_<suffix>/ folder). An agent knows immediately what this does. It stops short of naming a sibling such as gograph_session_end or gograph_session_audit to distinguish scope, so it is clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides an explicit WHEN TO USE line ('Call after auditing to keep the repository clean'), states 'No prerequisites', and documents the blocking condition ('refuses while any other caller is still live'). It does not name an alternative tool for ending a specific session instead of doing a bulk sweep, so the contrast with siblings is only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.