{"record":{"id":"3304a668eded8040","repo":"koala73/worldmonitor","slug":"tool-output-exceeded-the-safe-output-limit","errorCode":null,"errorMessage":"Tool output exceeded the safe output limit.","messagePattern":"Tool output exceeded the safe output limit\\.","errorType":"exception","errorClass":"SafeWebMcpError","httpStatus":null,"severity":"error","filePath":"src/services/webmcp.ts","lineNumber":796,"sourceCode":"          `Dashboard unavailable: ${boundedText(error.message, 160)} Reason: ${error.reason}.`,\n          'unavailable',\n        );\n      }\n      if (error instanceof DashboardPanelCatalogError) {\n        throw new SafeWebMcpError(error.message, 'validation');\n      }\n      if (error instanceof MissionPresetCatalogError) {\n        throw new SafeWebMcpError(error.message, 'validation');\n      }\n      throw new SafeWebMcpError(TOOL_FAILURE_MESSAGES[name]);\n    }\n  };\n}\n\nfunction enforceOutputBudget(value: unknown): void {\n  const serialized = JSON.stringify(value);\n  if (typeof serialized !== 'string' || serialized.length > MAX_OUTPUT_CHARS) {\n    throw new SafeWebMcpError('Tool output exceeded the safe output limit.');\n  }\n}\n\nfunction structuredResultReasons(result: Record<string, unknown>): string[] {\n  const reasons = typeof result.reason === 'string' ? [result.reason] : [];\n  if (!Array.isArray(result.targets)) return reasons;\n  for (const target of result.targets) {\n    if (target && typeof target === 'object' && 'reason' in target) {\n      const reason = (target as { reason?: unknown }).reason;\n      if (typeof reason === 'string') reasons.push(reason);\n    }\n  }\n  return reasons;\n}\n\nconst VALIDATION_DENIAL_REASONS = new Set([\n  'malformed_arguments',\n  'invalid_action',","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/koala73/worldmonitor/blob/9361220cc013571781071f0206e4d80fd14b2f7f/src/services/webmcp.ts#L778-L814","documentation":"SafeWebMcpError thrown by enforceOutputBudget in the browser WebMCP tool layer when a tool result, once JSON-serialized, exceeds the maximum allowed output size. It is a hard safety cap after any graceful truncation: oversized results are refused rather than shipped, and the generic message deliberately avoids echoing untrusted tool content.","triggerScenarios":"Thrown at src/services/webmcp.ts:303 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the tool's requested scope/limit so the result fits the budget","Apply tool-specific truncation before the global budget check","Split large queries into narrower invocations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9361220cc013571781071f0206e4d80fd14b2f7f","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}