{"record":{"id":"4239852ecab03692","repo":"mastra-ai/mastra","slug":"knowledge-read-requires-id-or-name","errorCode":null,"errorMessage":"knowledge_read requires id or name.","messagePattern":"knowledge_read requires id or name\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/memory/src/processors/observational-memory/subconscious/knowledge-tools.ts","lineNumber":211,"sourceCode":"        limit: { type: 'integer', minimum: 1, maximum: MAX_LIMIT },\n      },\n      additionalProperties: false,\n    } satisfies JSONSchema7,\n    execute: async (input, context) => {\n      const {\n        id,\n        name,\n        relationship = 'about',\n        cursor,\n        limit: requestedLimit,\n      } = input as {\n        id?: string;\n        name?: string;\n        relationship?: 'about' | 'mentioning' | 'related';\n        cursor?: string;\n        limit?: number;\n      };\n      if (!id && !name) throw new Error('knowledge_read requires id or name.');\n      const scope = fixedScope ?? resolveScope(context as KnowledgeToolContext);\n      const store = await getKnowledgeStore(memory);\n      const node = id ? await store.getNode(id) : await store.resolveNode({ name: name!, scope });\n      if (!node || node.mergedInto || !isKnowledgeScopeVisible(node.scope, scope)) return { found: false };\n      const query =\n        relationship === 'related'\n          ? store.listKnowledgeRelatedTo\n          : relationship === 'mentioning'\n            ? store.listKnowledgeMentioning\n            : store.listKnowledgeAbout;\n      const result = await query.call(store, {\n        node,\n        scope,\n        after: cursor,\n        limit: normalizeLimit(requestedLimit),\n      });\n      return {\n        found: true,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/memory/src/processors/observational-memory/subconscious/knowledge-tools.ts#L193-L229","documentation":"The knowledge_read tool fetches a single node either by its ID or by resolving its name within the caller's scope. Because the input schema leaves both optional, the execute handler performs an explicit check and throws when neither is provided, since there would be no way to identify the node. This is a tool-input validation error, typically raised when the LLM calls the tool with an empty or malformed arguments object.","triggerScenarios":"The curator/learner agent calls knowledge_read with arguments {} or only optional fields (relationship, cursor, limit), omitting both id and name.","commonSituations":"LLM hallucinating a call with no selectors; prompt templates that under-specify the tool's arguments; programmatic tool invocations that pass an empty object.","solutions":["Include either id (node ID) or name (resolvable node name) in the knowledge_read input.","If the node is known by name only, pass name and ensure it resolves within the caller's scope.","Strengthen the tool description / agent instructions so the model always supplies id or name.","In programmatic callers, validate the args object before execute()."],"exampleFix":"// before\nawait tools.knowledge_read.execute({ limit: 5 }, ctx);\n// after\nawait tools.knowledge_read.execute({ id: 'node_abc' }, ctx); // or { name: 'Deployment Guide' }","handlingStrategy":"validation","validationCode":"type ReadArgs = { id?: string; name?: string; relationship?: string; cursor?: string; limit?: number };\nfunction canRead(args: ReadArgs): boolean {\n  return typeof args.id === 'string' || typeof args.name === 'string';\n}\nif (!canRead(args)) throw new Error('knowledge_read needs id or name');","typeGuard":"function hasReadSelector(a: unknown): a is { id: string } | { name: string } {\n  const x = a as { id?: unknown; name?: unknown };\n  return typeof x?.id === 'string' || typeof x?.name === 'string';\n}","tryCatchPattern":"try {\n  return await tools.knowledge_read.execute(args, ctx);\n} catch (e) {\n  if (e instanceof Error && e.message === 'knowledge_read requires id or name.') {\n    return { found: false, reason: 'missing-selector' };\n  }\n  throw e;\n}","preventionTips":["Document in the tool description that id or name is mandatory.","Wrap the tool to default-fill name from the agent's current topic.","Validate args before execute() in programmatic callers.","Constrain the agent's prompt so it never emits empty selectors."],"tags":["tool-input-validation","knowledge-tools","missing-argument","llm-tool-call"],"backgroundTag":"missing-required-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}