{"record":{"id":"67711d96a6468d26","repo":"JuliusBrussee/caveman","slug":"cave-tool-search-result-limit","errorCode":null,"errorMessage":"cave_tool_search_result_limit","messagePattern":"cave_tool_search_result_limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/runtime.ts","lineNumber":3093,"sourceCode":"        } catch {\n          continue;\n        }\n        if (!isRecord(parsed) || typeof parsed.name !== \"string\" ||\n            typeof parsed.description !== \"string\" || !isRecord(parsed.input)) continue;\n        const haystack = `${parsed.name} ${parsed.description} ${JSON.stringify(parsed.input)}`.toLowerCase();\n        const score = terms.reduce((total, term) => total + (haystack.includes(term) ? 1 : 0), 0);\n        if (score > 0) hits.push({ score, value: parsed, handle });\n      }\n      hits.sort((first, second) => second.score - first.score ||\n        String(first.value.name).localeCompare(String(second.value.name)));\n      const selected = hits.slice(0, 4);\n      for (const hit of selected) {\n        for (const item of trace ?? []) {\n          if (item.recoveryHandle === hit.handle) item.recoveryUsed = true;\n        }\n      }\n      const text = JSON.stringify(selected.map((hit) => hit.value));\n      if (text.length > 8_192) throw new Error(\"cave_tool_search_result_limit\");\n      return {\n        content: [{ type: \"text\", text }],\n        details: { recovery: \"tool_schema_search\", hits: selected.length },\n      };\n    },\n  };\n}\n\nfunction validEngineTokenCount(value: unknown): number | undefined {\n  return Number.isSafeInteger(value) && Number(value) >= 0 ? Number(value) : undefined;\n}\n\nfunction localMemoryTools(\n  definition: NonNullable<AgentDefinition[\"memory\"]>,\n  agentId: string,\n  config: MemoryStoreConfig | undefined,\n): AgentTool<TSchema>[] {\n  // Defense in depth: memory() already rejects a non-local provenance/consent at","sourceCodeStart":3075,"sourceCodeEnd":3111,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/agent/src/runtime.ts#L3075-L3111","documentation":"Error \"cave_tool_search_result_limit\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/agent/src/runtime.ts:3093 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the tool search result count or raise the configured result limit."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}