{"record":{"id":"85a6e4360e06c956","repo":"rohitg00/agentmemory","slug":"mem-search-format-must-be-one-of-full-compac","errorCode":null,"errorMessage":"mem::search: format must be one of 'full', 'compact', or 'narrative'","messagePattern":"mem::search: format must be one of 'full', 'compact', or 'narrative'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/functions/search.ts","lineNumber":435,"sourceCode":"      const filterAgentId = wildcardAgent\n        ? undefined\n        : explicitAgentId ?? envAgentId;\n      if (\n        isolated &&\n        !wildcardAgent &&\n        !explicitAgentId &&\n        !envAgentId\n      ) {\n        throw new Error(\n          \"mem::search: AGENTMEMORY_AGENT_SCOPE=isolated is set but no \" +\n            \"agent id is available (env AGENT_ID unset and no explicit \" +\n            \"agentId in the call). Refusing to read cross-agent rows. \" +\n            'Pass agentId: \"*\" to opt in to a wildcard read.',\n        );\n      }\n      const format = typeof data.format === 'string' ? data.format : 'full'\n      if (!['full', 'compact', 'narrative'].includes(format)) {\n        throw new Error(\"mem::search: format must be one of 'full', 'compact', or 'narrative'\")\n      }\n      let tokenBudget: number | undefined\n      if (data.token_budget !== undefined) {\n        if (!Number.isInteger(data.token_budget) || data.token_budget < 1) {\n          throw new Error('mem::search: token_budget must be a positive integer')\n        }\n        tokenBudget = data.token_budget\n      }\n\n      if (idx.size === 0) {\n        // Share one rebuild across concurrent cold-start queries so they\n        // don't each walk the whole corpus and saturate the pool.\n        if (!rebuildPromise) {\n          rebuildPromise = rebuildIndex(kv)\n            .then((count) => {\n              logger.info('Search index rebuilt', { entries: count })\n              return count\n            })","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/functions/search.ts#L417-L453","documentation":"mem::search supports an optional format parameter controlling output shape; it defaults to 'full' and must be one of 'full', 'compact', or 'narrative'. Any other string is rejected before the search executes.","triggerScenarios":"Calling mem::search with format set to an unsupported value such as 'text', 'json', 'verbose', 'summary', or a typo like 'narative'.","commonSituations":"Clients written against an older/newer API surface with different format names; free-form UI dropdown values forwarded directly; case-sensitivity mistakes ('Full').","solutions":["Use exactly one of 'full', 'compact', or 'narrative' (lowercase).","Omit format to get the 'full' default.","Whitelist the value on the caller side before forwarding user-selected options.","Fix case mismatches by lowercasing input first."],"exampleFix":"// before\nawait trigger({ function_id: 'mem::search', payload: { query: q, format: opts.mode } });\n// after\nconst FORMATS = ['full', 'compact', 'narrative'];\nconst format = FORMATS.includes(opts.mode) ? opts.mode : undefined;\nawait trigger({ function_id: 'mem::search', payload: { query: q, format } });","handlingStrategy":"type-guard","validationCode":"const FORMATS = ['full', 'compact', 'narrative'] as const;\ntype SearchFormat = typeof FORMATS[number];\nfunction toFormat(v: unknown): SearchFormat | undefined {\n  return typeof v === 'string' && (FORMATS as readonly string[]).includes(v) ? v as SearchFormat : undefined;\n}","typeGuard":"function isSearchFormat(v: unknown): v is 'full' | 'compact' | 'narrative' {\n  return v === 'full' || v === 'compact' || v === 'narrative';\n}","tryCatchPattern":"try {\n  return await trigger({ function_id: 'mem::search', payload: { query, format } });\n} catch (e) {\n  if (String(e.message).includes(\"format must be one of\")) {\n    return await trigger({ function_id: 'mem::search', payload: { query } });\n  }\n  throw e;\n}","preventionTips":["Use a const-asserted union type for format values in client code.","Lowercase/trim user-selected formats before forwarding.","Omit format when the default ('full') is acceptable.","Keep client enum lists in sync with server releases."],"tags":["validation","search","enum"],"backgroundTag":"invalid-enum-parameter","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}