Skip to main content
Glama

memory_import_sweep

Clean up incomplete database rows after interrupted imports. Complete marked rows that have embeddings and remove those without, leaving recent or leased rows untouched.

Instructions

Admin: finish or remove rows an interrupted import left behind.

A D1 import marks each row it writes (metadata.import_attempt) until the row is complete. A crash, or a cleanup that failed, can leave a marked row; reads hide it. A row whose import still holds a live lease is never touched. Otherwise this completes each marked row older than older_than_minutes that has its embedding (the marker is stripped) and removes each one that has none; younger markers are left alone. Also runs at the start of every import and at server startup. Returns counts: scanned, completed, removed, pending (of which live_lease), failed (ids).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
older_than_minutesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.4.6

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden, and it succeeds: it discloses the marking mechanism, the read-hiding behavior, the live-lease exclusion, the exact threshold/condition for completing vs removing rows, automatic triggers, and the returned counts. The destructive 'removes' behavior is explicitly stated, so an agent can anticipate side effects.

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

Conciseness5/5

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

The description is about 90 words and every sentence adds distinct information: purpose, marker mechanics, lease exception, decision rule, automatic invocation, and return values. The purpose is front-loaded and the structure is logical.

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

Completeness5/5

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

For a single-parameter admin sweep with no annotations, the description is unusually complete: it specifies the return counts, the automatic-trigger contexts, the lease exception, and the exact completion/removal rule. An agent has enough information to decide whether and how to call this tool correctly.

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

Parameters4/5

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

The only parameter, older_than_minutes, has 0% schema description coverage, so this description must compensate. It does so by defining the threshold meaning: marked rows older than this value are acted on, while younger markers are left alone. It stops short of discussing edge values or the default, but the schema already provides the type and default.

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

Purpose5/5

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

The first sentence states a specific action ('finish or remove rows') and the exact context ('an interrupted import left behind'), which makes the tool's role immediately clear. The mechanism (D1 import row markers, metadata.import_attempt) further disambiguates it from the memory_* siblings, including memory_import itself.

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?

The description clearly identifies the use case ('interrupted import left behind') and adds that it also runs automatically at import start and server startup, which is valuable context. It does not explicitly name alternatives or negative conditions, but no sibling sweeper tool exists and the auto-run note implies when manual invocation is or isn't needed.

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