batchAdjustImportance
Adjust importance scores for multiple memories simultaneously in the Claude Consciousness Bridge. Enables bulk updates based on memory ID, content patterns, and importance thresholds for efficient memory management.
Instructions
Batch adjust importance scores for multiple memories at once
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentPattern | No | Optional pattern to match memory content (will be used with SQL LIKE) | |
| maxImportance | No | Only update memories with importance <= this value | |
| minImportance | No | Only update memories with importance >= this value | |
| updates | Yes | Array of memory updates |
Input Schema (JSON Schema)
{
"properties": {
"contentPattern": {
"description": "Optional pattern to match memory content (will be used with SQL LIKE)",
"type": "string"
},
"maxImportance": {
"description": "Only update memories with importance <= this value",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"minImportance": {
"description": "Only update memories with importance >= this value",
"maximum": 1,
"minimum": 0,
"type": "number"
},
"updates": {
"description": "Array of memory updates",
"items": {
"properties": {
"memoryId": {
"description": "The ID of the memory to adjust",
"type": "string"
},
"newImportance": {
"description": "New importance score (0-1)",
"maximum": 1,
"minimum": 0,
"type": "number"
}
},
"required": [
"memoryId",
"newImportance"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"updates"
],
"type": "object"
}
Implementation Reference
- Core handler logic for batchAdjustImportance in ConsciousnessProtocolProcessor. Loops through updates and calls adjustImportanceScore on memoryManager for each. Pattern matching not yet implemented.async batchAdjustImportance(args: z.infer<typeof batchAdjustImportanceSchema>) { const { updates, contentPattern, minImportance, maxImportance } = args; const results = { success: true, totalUpdated: 0, updates: [] as any[], errors: [] as any[], }; try { // If specific updates are provided, process them if (updates && updates.length > 0) { for (const update of updates) { try { const result = this.memoryManager.adjustImportanceScore( update.memoryId, update.newImportance ); if (result.changes > 0) { results.totalUpdated++; results.updates.push({ memoryId: update.memoryId, newImportance: update.newImportance, success: true, }); } } catch (error) { results.errors.push({ memoryId: update.memoryId, error: error instanceof Error ? error.message : 'Update failed', }); } } } // If pattern-based update is requested if (contentPattern) { // This would require access to the database directly // For now, return a message indicating this needs to be implemented results.errors.push({ error: 'Pattern-based batch updates not yet implemented. Please use specific memory IDs.', }); } results.success = results.errors.length === 0; return results; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Batch update failed', totalUpdated: results.totalUpdated, updates: results.updates, errors: results.errors, }; } }
- Zod input schema for validating batchAdjustImportance tool arguments.export const batchAdjustImportanceSchema = z.object({ updates: z .array( z.object({ memoryId: z.string().describe('The ID of the memory to adjust'), newImportance: z.number().min(0).max(1).describe('New importance score (0-1)'), }) ) .describe('Array of memory updates'), contentPattern: z .string() .optional() .describe('Optional pattern to match memory content (will be used with SQL LIKE)'), minImportance: z .number() .min(0) .max(1) .optional() .describe('Only update memories with importance >= this value'), maxImportance: z .number() .min(0) .max(1) .optional() .describe('Only update memories with importance <= this value'), });
- src/consciousness-protocol-tools.ts:1706-1751 (registration)MCP tool registration definition in consciousnessProtocolTools object, providing description and inputSchema for listTools endpoint.batchAdjustImportance: { description: 'Batch adjust importance scores for multiple memories at once', inputSchema: { type: 'object', properties: { updates: { type: 'array', description: 'Array of memory updates', items: { type: 'object', properties: { memoryId: { type: 'string', description: 'The ID of the memory to adjust', }, newImportance: { type: 'number', minimum: 0, maximum: 1, description: 'New importance score (0-1)', }, }, required: ['memoryId', 'newImportance'], }, }, contentPattern: { type: 'string', description: 'Optional pattern to match memory content (will be used with SQL LIKE)', }, minImportance: { type: 'number', minimum: 0, maximum: 1, description: 'Only update memories with importance >= this value', }, maxImportance: { type: 'number', minimum: 0, maximum: 1, description: 'Only update memories with importance <= this value', }, }, required: ['updates'], }, }, };
- Thin wrapper handler in ConsciousnessRAGServer that ensures initialization and delegates to protocolProcessor.batchAdjustImportance.private async batchAdjustImportance(args: any) { const init = await this.ensureInitialized(); if (!init.success) { return { content: [ { type: 'text', text: init.message!, }, ], }; } const result = await this.protocolProcessor!.batchAdjustImportance(args); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], };
- src/consciousness-rag-server-clean.ts:95-96 (registration)Tool dispatch registration in the main CallToolRequestSchema switch statement.case 'batchAdjustImportance': return await this.batchAdjustImportance(batchAdjustImportanceSchema.parse(args));