Skip to main content
Glama
AgentWong

Knowledge Graph Memory Server

by AgentWong

delete_observations

Remove specific observations from entities in the knowledge graph to maintain accurate memory by deleting outdated or incorrect information.

Instructions

Delete specific observations from entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deletionsYes

Implementation Reference

  • The actual database operation implementation for deleting observations from an entity.
    async def delete_observations(
        self, 
        deletions: List[Dict[str, Any]], 
        batch_size: int = 1000
    ) -> None:
        """Remove specific observations from entities using batch processing."""
        async with self.pool.get_connection() as conn:
            async with self.pool.transaction(conn):
                for i in range(0, len(deletions), batch_size):
                    batch = deletions[i:i + batch_size]
                    
                    for deletion in batch:
                        entity_name = sanitize_input(deletion["entityName"])
                        to_delete = set(deletion["observations"])
    
                        cursor = await conn.execute(
                            "SELECT observations FROM entities WHERE name = ?",
                            (entity_name,)
                        )
                        result = await cursor.fetchone()
                        if result:
                            current_obs = result['observations'].split(',') if result['observations'] else []
                            updated_obs = [obs for obs in current_obs if obs not in to_delete]
                            
                            await conn.execute(
                                "UPDATE entities SET observations = ? WHERE name = ?",
                                (','.join(updated_obs), entity_name)
                            )

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/AgentWong/optimized-memory-mcp-server'

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