delete_observations
Remove specific observations from entities in a knowledge graph to maintain accurate semantic code indexing and search capabilities.
Instructions
Delete specific observations from entities in the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deletions | Yes |
Implementation Reference
- The primary handler for the 'delete_observations' tool. Validates the input arguments and delegates the deletion to the knowledge graph manager.export const deleteObservationsHandler: ToolHandler = async (args) => { if (!args.deletions || !Array.isArray(args.deletions)) { throw new Error("The 'deletions' parameter is required and must be an array"); } // Valider chaque suppression for (const deletion of args.deletions) { if (!deletion.entityName || typeof deletion.entityName !== 'string') { throw new Error("Each deletion must have an 'entityName' string property"); } if (!deletion.observations || !Array.isArray(deletion.observations)) { throw new Error("Each deletion must have an 'observations' array property"); } } try { await knowledgeGraphManager.deleteObservations(args.deletions); return { content: [{ type: "text", text: "Observations deleted successfully" }] }; } catch (error) { console.error("Error in delete_observations tool:", error); throw error; } };
- The tool definition including name, description, and input schema for 'delete_observations'.export const deleteObservationsTool: ToolDefinition = { name: "delete_observations", description: "Delete specific observations from entities in the knowledge graph", inputSchema: { type: "object", properties: { deletions: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity containing the observations" }, observations: { type: "array", items: { type: "string" }, description: "An array of observations to delete" }, }, required: ["entityName", "observations"], }, }, }, required: ["deletions"], }, };
- Core helper function in KnowledgeGraphManager that performs the actual deletion of observations by filtering the entity's observations array and saving the graph.async deleteObservations(deletions: DeletionInput[]): Promise<void> { const graph = await this.loadGraph(); deletions.forEach(d => { const entity = graph.entities.find(e => e.name === d.entityName); if (entity) { entity.observations = entity.observations.filter(o => !d.observations.includes(o)); } }); await this.saveGraph(graph); }
- src/core/registry.ts:249-252 (registration)The auto-registration system that discovers and registers tools from build/tools/graph including delete_observations via its Tool and Handler exports.export const autoRegistry = new AutoRegistry(); /** * Fonction utilitaire pour initialiser le registre automatique
- build/tools/graph-tools.js:93-116 (schema)Alternative schema definition for delete_observations in the graph tools array (possibly for manual use or dispatcher).name: "delete_observations", description: "Delete specific observations from entities in the knowledge graph", inputSchema: { type: "object", properties: { deletions: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity containing the observations" }, observations: { type: "array", items: { type: "string" }, description: "An array of observations to delete" }, }, required: ["entityName", "observations"], }, }, }, required: ["deletions"], }, },
- build/tools/graph-tools.js:187-189 (handler)Dispatcher handler case for delete_observations in executeGraphTool function.case "delete_observations": await knowledgeGraphManager.deleteObservations(args.deletions); return { content: [{ type: "text", text: "Observations deleted successfully" }] };