ad4m_classify
Determines the correct layer (ad4m, local, env, or relay) for a piece of information before storing it in memory. Run this to avoid misclassification when writing memory.
Instructions
Classify a piece of information by which layer it belongs to: ad4m, local, env, or relay. Run this BEFORE ad4m_write_memory if unsure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The information or description to classify |
Implementation Reference
- src/index.ts:67-79 (handler)TypeScript version of the core classification logic with proper type annotations (Layer, LayerRule).
function classifyContent(content: string): { layer: Layer; reason: string; action: string } { const lower = content.toLowerCase(); for (const [layer, cfg] of Object.entries(TAXONOMY) as [Layer, LayerRule][]) { if (cfg.keywords.some((kw) => lower.includes(kw))) { return { layer, reason: cfg.reason, action: cfg.action }; } } return { layer: "ad4m", reason: "No exclusion pattern matched — defaulting to semantic memory.", action: "Use ad4m_write_memory. If uncertain, run ad4m_classify with more specific content.", }; } - src/index.ts:369-374 (schema)The tool registration and schema definition (TypeScript version). Defines the 'content' input as a required string using Zod. The handler inline calls classifyContent().
// 7. ad4m_classify server.tool("ad4m_classify", "Classify a piece of information by which layer it belongs to: ad4m, local, env, or relay. Run this BEFORE ad4m_write_memory if unsure.", { content: z.string().describe("The information or description to classify") }, async ({ content }) => ok(classifyContent(content)) );