twining_prune_graph
Clean up a knowledge graph by removing orphaned entities that have no relations. Optionally filter by entity type or run in dry-run mode to preview changes.
Instructions
Remove orphaned knowledge graph entities that have no relations. Use this to clean up stale or disconnected entities. Optionally filter by entity type to only prune certain kinds.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_types | No | Only prune orphans of these types (e.g., ["concept", "file"]). If omitted, prunes all orphan types. | |
| dry_run | No | If true, report orphans without removing them (default: false) |
Implementation Reference
- src/tools/graph-tools.ts:184-222 (handler)The handler for the twining_prune_graph tool, which delegates to the engine's prune method.
// twining_prune_graph — Remove orphaned graph entities server.registerTool( "twining_prune_graph", { description: "Remove orphaned knowledge graph entities that have no relations. Use this to clean up stale or disconnected entities. Optionally filter by entity type to only prune certain kinds.", inputSchema: { entity_types: z .array(z.string()) .optional() .describe( 'Only prune orphans of these types (e.g., ["concept", "file"]). If omitted, prunes all orphan types.', ), dry_run: z .boolean() .optional() .describe( "If true, report orphans without removing them (default: false)", ), }, }, async (args) => { try { const result = await engine.prune( args.entity_types, args.dry_run ?? false, ); return toolResult(result); } catch (e) { if (e instanceof TwiningError) { return toolError(e.message, e.code); } return toolError( e instanceof Error ? e.message : "Unknown error", "INTERNAL_ERROR", ); } }, );