update_memory
Modify existing stored data by editing or appending to specific memory entries in the Hi-AI assistant system.
Instructions
update|modify|change|edit memory - Update existing memory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Memory key to update | |
| value | Yes | New value | |
| append | No | Append to existing value |
Implementation Reference
- src/tools/memory/updateMemory.ts:24-51 (handler)Executes the update_memory tool: updates or appends to an existing memory entry using MemoryManager, returns success/error text.export async function updateMemory(args: { key: string; value: string; append?: boolean }): Promise<ToolResult> { const { key: updateKey, value: updateValue, append = false } = args; try { const mm = MemoryManager.getInstance(); const existingMemory = mm.recall(updateKey); if (existingMemory) { const newValue = append ? existingMemory.value + ' ' + updateValue : updateValue; mm.update(updateKey, newValue); return { content: [{ type: 'text', text: `✓ ${append ? 'Appended to' : 'Updated'} memory: "${updateKey}"` }] }; } else { return { content: [{ type: 'text', text: `✗ Memory not found: "${updateKey}". Use save_memory to create new memory.` }] }; } } catch (error) { return { content: [{ type: 'text', text: `✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
- ToolDefinition for update_memory including input schema (key:string required, value:string required, append?:boolean) and metadata.export const updateMemoryDefinition: ToolDefinition = { name: 'update_memory', description: 'update|modify|change|edit memory - Update existing memory', inputSchema: { type: 'object', properties: { key: { type: 'string', description: 'Memory key to update' }, value: { type: 'string', description: 'New value' }, append: { type: 'boolean', description: 'Append to existing value' } }, required: ['key', 'value'] }, annotations: { title: 'Update Memory', audience: ['user', 'assistant'] } };
- src/index.ts:646-647 (registration)Registers the handler dispatch for 'update_memory' tool in the executeToolCall switch statement.case 'update_memory': return await updateMemory(args as any) as CallToolResult;
- src/index.ts:130-130 (registration)Adds updateMemoryDefinition to the tools array used for ListToolsRequestHandler.updateMemoryDefinition,
- src/index.ts:68-68 (registration)Imports the updateMemory handler and definition from the tool module.import { updateMemory, updateMemoryDefinition } from './tools/memory/updateMemory.js';