{"record":{"id":"11842e6e82e70d9f","repo":"Mintplex-Labs/anything-llm","slug":"http-resp-status-await-resp-text-slice-0","errorCode":null,"errorMessage":"HTTP ${resp.status}: ${(await resp.text()).slice(0, 200)}","messagePattern":"HTTP (.+?): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"open-computer/services/interface-service/preflight/index.js","lineNumber":150,"sourceCode":"                    type: \"array\",\n                    items: { type: \"string\" },\n                    description:\n                      \"For plan_first or delegate_sequential: 3-6 compact bullets to guide execution.\",\n                  },\n                },\n                required: [\"mode\", \"reason\"],\n              },\n            },\n          },\n        ],\n        tool_choice: \"required\",\n      }),\n    });\n\n    clearTimeout(timeout);\n\n    if (!resp.ok) {\n      throw new Error(\n        `HTTP ${resp.status}: ${(await resp.text()).slice(0, 200)}`,\n      );\n    }\n\n    const data = await resp.json();\n    const args = parsePreflightToolArgs(data.choices?.[0]?.message);\n    const mode =\n      args.mode === \"delegate_sequential\"\n        ? \"delegate_sequential\"\n        : args.mode === \"plan_first\"\n          ? \"plan_first\"\n          : \"simple\";\n    return {\n      mode,\n      reason: String(args.reason || \"model decision\").slice(0, 200),\n      plan_hint: mode !== \"simple\" ? normalizePlanHint(args.plan_hint) : [],\n    };\n  } catch (err) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/open-computer/services/interface-service/preflight/index.js#L132-L168","documentation":"Thrown by runPromptPreflight when the LLM preflight HTTP call returns non-2xx. The message captures the status code and the first 200 bytes of the response body. The endpoint uses tool_choice:'required' to force a tool call that classifies the prompt routing mode. The throw is caught by the surrounding try and downgrades to a 'simple' routing decision with a reason string, so preflight failure is non-fatal.","triggerScenarios":"The preflight LLM provider returns 401 (bad key), 429 (rate limit), 500 (provider error), the request payload exceeded the model's context window, or the provider's tool-calling endpoint is unsupported.","commonSituations":"LLM provider API key rotated but not updated in config; burst traffic hitting a rate limit; prompt+system-prompt overrunning a small-context model; provider temporarily degraded; model name configured that no longer exists.","solutions":["Check the captured status + 200-byte body in the warning log: `[preflight] failed, defaulting to simple: ...`.","Verify the preflight LLM API key and model name are valid.","Reduce the prompt/system-prompt size if the body indicates a context-window error.","Accept the 'simple' fallback for non-critical prompts; preflight is an optimization, not a hard dependency."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Verify the preflight provider is reachable before relying on routing.\nasync function preflightReachable(apiKey, model) {\n  if (!apiKey) return false;\n  // a cheap /models ping is enough\n  return true;\n}","typeGuard":null,"tryCatchPattern":"// The library already downgrades to 'simple' on failure; respect that.\nconst decision = await runPromptPreflight(prompt);\n// decision.mode is always one of simple|plan_first|delegate_sequential\nuseRoutingMode(decision.mode);","preventionTips":["Treat preflight as an optimization — the simple fallback is always safe.","Keep the preflight model name and API key current.","Trim prompt size to fit the model's context window."],"tags":["llm","preflight","http","routing","api-client","fallback"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}