{"record":{"id":"f93a87056075683e","repo":"thedotmack/claude-mem","slug":"anthropic-api-rejected-request-with-http-400-this","errorCode":null,"errorMessage":"Anthropic API rejected request with HTTP 400: this model does not support the `effort` parameter. CLAUDE_CODE_EFFORT_LEVEL is likely leaking into the SDK subprocess env via ~/.claude-mem/.env — remove it or scope it to models that support effort. See https://github.com/thedotmack/claude-mem/issues/2357.","messagePattern":"Anthropic API rejected request with HTTP 400: this model does not support the `effort` parameter\\. CLAUDE_CODE_EFFORT_LEVEL is likely leaking into the SDK subprocess env via ~/\\.claude-mem/\\.env — remove it or scope it to models that support effort\\. See https://github\\.com/thedotmack/claude-mem/issues/2357\\.","errorType":"console","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/services/worker/ClaudeProvider.ts","lineNumber":139,"sourceCode":"  // the pattern in GeminiProvider.classifyGeminiError / classifyOpenRouterError\n  // (see #2357: the SDK forwards `effort` to the Messages API when\n  // CLAUDE_CODE_EFFORT_LEVEL leaks into the subprocess env, and models like\n  // Haiku/Sonnet 4.5 reject with 400 — without this branch the default\n  // `transient` classification retried indefinitely).\n  if (errAny.status === 400) {\n    // Inspect both the message and any structured body for the effort marker.\n    const bodyText = (() => {\n      const body = errAny.body;\n      if (typeof body === 'string') return body;\n      if (body && typeof body === 'object') {\n        try { return JSON.stringify(body); } catch { return ''; }\n      }\n      return '';\n    })();\n    const haystack = `${message}\\n${bodyText}`;\n    if (/effort parameter/i.test(haystack) && !effortHintLogged) {\n      effortHintLogged = true;\n      logger.warn(\n        'SDK',\n        'Anthropic API rejected request with HTTP 400: this model does not support the `effort` parameter. ' +\n          'CLAUDE_CODE_EFFORT_LEVEL is likely leaking into the SDK subprocess env via ~/.claude-mem/.env — ' +\n          'remove it or scope it to models that support effort. See https://github.com/thedotmack/claude-mem/issues/2357.',\n        { status: 400 }\n      );\n    }\n    return new ClassifiedProviderError(\n      message || 'Anthropic bad request (status 400)',\n      { kind: 'unrecoverable', cause: err },\n    );\n  }\n\n  // Status-less Anthropic 400s — SDK wrapping can drop `.status`, leaving only\n  // the message or an `invalid_request_error` body; classify those as\n  // unrecoverable so the worker stops retrying a permanent config error (#2656).\n  // The status guard keeps statused 4xx/5xx on their own branches.\n  if (","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker/ClaudeProvider.ts#L121-L157","documentation":"classifyClaudeError detects an HTTP 400 from the Anthropic API whose message mentions the 'effort parameter'. This means CLAUDE_CODE_EFFORT_LEVEL is set in ~/.claude-mem/.env and leaks into the SDK subprocess, causing the API to reject requests for models that do not support the effort parameter. The warning links issue #2357 and is logged once (effortHintLogged guard).","triggerScenarios":"A query() call to the Claude Agent SDK fails with HTTP 400 containing 'effort parameter'; the haystack (message + body) matches /effort parameter/i and this is the first occurrence in the process.","commonSituations":"User copied CLAUDE_CODE_EFFORT_LEVEL into ~/.claude-mem/.env intending it for Claude Code but not the SDK subprocess; switched to a model (e.g. non-reasoning or older model) that rejects the effort parameter; recent claude-mem version began passing full env through.","solutions":["Remove CLAUDE_CODE_EFFORT_LEVEL from ~/.claude-mem/.env","Or scope it: only set effort for models that support it (gate on model name)","Restart the claude-mem worker so the cleaned env is picked up","Retry the operation and confirm requests no longer return HTTP 400"],"exampleFix":"// before (~/.claude-mem/.env)\nCLAUDE_CODE_EFFORT_LEVEL=high\n// after: remove the line, or gate it per model\n// CLAUDE_CODE_EFFORT_LEVEL=high  # only when model supports effort, e.g. opus-plan","handlingStrategy":"validation","validationCode":"// Check before starting the SDK subprocess\nimport { readFileSync, existsSync } from 'fs';\nconst envPath = `${process.env.HOME}/.claude-mem/.env`;\nif (existsSync(envPath) && readFileSync(envPath, 'utf8').includes('CLAUDE_CODE_EFFORT_LEVEL')) {\n  console.warn('CLAUDE_CODE_EFFORT_LEVEL will leak into SDK env; remove it for models without effort support');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await query({ ... });\n} catch (err) {\n  if (/effort parameter/i.test(String(err.message))) {\n    delete process.env.CLAUDE_CODE_EFFORT_LEVEL; // scrub and retry\n  }\n}","preventionTips":["Keep model-specific flags out of ~/.claude-mem/.env","Only set CLAUDE_CODE_EFFORT_LEVEL for models that support the effort parameter","After changing .env, restart the worker so the env is re-read","Watch for HTTP 400 responses mentioning unsupported parameters"],"tags":["anthropic","http-400","env","configuration","sdk"],"backgroundTag":"invalid-env-var-value","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}