Skip to main content
Glama

delete_observations

Remove specific observations from entities in the knowledge graph. Use this tool to maintain data accuracy by deleting outdated or incorrect entity-associated observations.

Instructions

Delete specific observations from entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deletionsYesArray of entity observations to delete

Implementation Reference

  • Full tool registration including the handler execute function that implements delete_observations by filtering observations from enhancedEntities in memoryStore after fuzzy entity matching.
    server.addTool({
      name: 'delete_observations',
      description: 'Delete specific observations from entities in the knowledge graph',
      parameters: Schemas.DeleteObservationsSchema,
      execute: async (args) => {
        const results = {
          updated: [] as string[],
          notFound: [] as string[]
        };
    
        for (const item of args.deletions) {
          try {
            // First, find the entity directly
            const entity = graph.entities.get(item.entityName);
            
            if (!entity) {
              // If not found directly, try to find similar entities
              const similarEntities = await memoryStore.findSimilar(item.entityName);
              
              if (similarEntities.length === 0) {
                // No matching entity found
                results.notFound.push(item.entityName);
                continue;
              }
              
              // Use the first similar entity
              item.entityName = similarEntities[0];
            }
            
            // Get enhanced entity from memory store (access private property carefully)
            const enhancedEntityMap = (memoryStore as any).enhancedEntities;
            const enhancedEntity = enhancedEntityMap?.get(item.entityName);
            
            if (!enhancedEntity) {
              results.notFound.push(item.entityName);
              continue;
            }
            
            // Track if any observations were removed
            let observationsRemoved = false;
            
            // Loop through the observations to delete
            for (const observationToDelete of item.observations) {
              // Filter out observations that match the text
              const originalLength = enhancedEntity.observations.length;
              enhancedEntity.observations = enhancedEntity.observations.filter((obs: { text: string }) => 
                !obs.text.includes(observationToDelete)
              );
              
              if (enhancedEntity.observations.length < originalLength) {
                observationsRemoved = true;
              }
            }
            
            if (observationsRemoved) {
              results.updated.push(item.entityName);
            } else {
              results.notFound.push(item.entityName);
            }
          } catch (error) {
            console.error(`Error deleting observations for ${item.entityName}:`, error);
            results.notFound.push(item.entityName);
          }
        }
    
        // Save changes
        await memoryStore.save();
    
        // Return as string
        return JSON.stringify({
          updated: results.updated.length > 0 ? results.updated : null,
          notFound: results.notFound.length > 0 ? results.notFound : null,
          message: `Removed observations from ${results.updated.length} entities. ${results.notFound.length} entities not found or observations not found.`
        });
      }
    });
  • Zod schema defining the input parameters for the delete_observations tool.
    export const DeleteObservationsSchema = z.object({
      deletions: z.array(z.object({
        entityName: z.string().min(1).describe('Name of the entity to remove observations from'),
        observations: z.array(z.string()).describe('Observations to remove from the entity')
      })).describe('Array of entity observations to delete')
    });
  • Supporting method in KnowledgeGraph class for deleting observations from an entity (used in other tools like upsert_entities).
    deleteObservations(entityName: string, observations: string[]): boolean {
      const entity = this.entities.get(entityName);
      if (!entity) {
        return false;
      }
      
      // Remove each observation if it exists
      for (const observation of observations) {
        const index = entity.observations.indexOf(observation);
        if (index !== -1) {
          entity.observations.splice(index, 1);
        }
      }
      
      return true;
    }
  • Tool registration within registerMemoryTools function.
    server.addTool({
      name: 'delete_observations',
      description: 'Delete specific observations from entities in the knowledge graph',
      parameters: Schemas.DeleteObservationsSchema,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Delete' implies a destructive mutation, the description doesn't specify whether deletions are permanent, reversible, require specific permissions, or have side effects on related data. It also doesn't describe what happens if referenced entities or observations don't exist, or what the tool returns upon completion.

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 a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a tool with one parameter and good schema documentation, though it could benefit from additional context about usage and behavior.

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

Completeness2/5

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

For a destructive mutation tool with no annotations and no output schema, the description is inadequate. It doesn't address critical behavioral aspects like permanence, error handling, or return values. Given the complexity of modifying a knowledge graph and the presence of multiple deletion-related sibling tools, more context about when and how to use this tool is needed.

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 the schema already fully documents the 'deletions' parameter structure. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain what constitutes an 'observation', provide examples of observation values, or clarify the relationship between entities and their observations.

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?

The description clearly states the action ('Delete') and target ('specific observations from entities in the knowledge graph'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish itself from sibling tools like 'delete_entities' or 'delete_relations', which handle different deletion operations in the same knowledge graph context.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'delete_entities' (which deletes entire entities) or 'delete_relations' (which deletes relationships). There's no mention of prerequisites, constraints, or typical scenarios where deleting observations would be appropriate versus other deletion operations.

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

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/flight505/mcp-think-tank'

If you have feedback or need assistance with the MCP directory API, please join our Discord server