update_memory_block
Modify the content and metadata of a memory block in the Letta system by specifying its ID, enabling updates to stored information for agent operations.
Instructions
Update the contents and metadata of a memory block. Use list_memory_blocks to find block IDs, or read_memory_block to see current content before updating.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| block_id | Yes | ID of the memory block to update | |
| value | No | New value for the memory block (optional) | |
| metadata | No | New metadata for the memory block (optional) | |
| agent_id | No | Optional agent ID for authorization |
Implementation Reference
- The handler function that implements the core logic for the 'update_memory_block' tool: validates inputs, prepares update data, makes a PATCH request to the Letta API to update the memory block, and returns the response.export async function handleUpdateMemoryBlock(server, args) { try { // Validate arguments if (!args?.block_id) { throw new Error('Missing required argument: block_id'); } if (!args?.value && !args?.metadata) { throw new Error('Either value or metadata must be provided'); } // Headers for API requests const headers = server.getApiHeaders(); // If agent_id is provided, set the user_id header if (args.agent_id) { headers['user_id'] = args.agent_id; } // Prepare update data const updateData = {}; if (args.value !== undefined) { updateData.value = args.value; } if (args.metadata !== undefined) { updateData.metadata = args.metadata; } // Update the memory block const response = await server.api.patch(`/blocks/${args.block_id}`, updateData, { headers, }); // Format the response return { content: [ { type: 'text', text: JSON.stringify(response.data), }, ], }; } catch (error) { server.createErrorResponse(error); } }
- The tool definition including name, description, and input schema for 'update_memory_block'.export const updateMemoryBlockToolDefinition = { name: 'update_memory_block', description: 'Update the contents and metadata of a memory block. Use list_memory_blocks to find block IDs, or read_memory_block to see current content before updating.', inputSchema: { type: 'object', properties: { block_id: { type: 'string', description: 'ID of the memory block to update', }, value: { type: 'string', description: 'New value for the memory block (optional)', }, metadata: { type: 'object', description: 'New metadata for the memory block (optional)', }, agent_id: { type: 'string', description: 'Optional agent ID for authorization', }, }, required: ['block_id'], }, };
- src/tools/index.js:167-168 (registration)Registration of the 'update_memory_block' handler in the central tool dispatch switch statement within registerToolHandlers.case 'update_memory_block': return handleUpdateMemoryBlock(server, request.params.arguments);
- src/tools/index.js:25-27 (registration)Import of the handler and tool definition for 'update_memory_block'.handleUpdateMemoryBlock, updateMemoryBlockToolDefinition, } from './memory/update-memory-block.js';
- src/tools/index.js:111-111 (registration)Inclusion of updateMemoryBlockToolDefinition in the allTools array used for registration.updateMemoryBlockToolDefinition,