thedotmack/claude-mem · error
Anthropic API rejected request with HTTP 400: this model…
Error message
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.
What it means
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).
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
Example fix
// before (~/.claude-mem/.env) CLAUDE_CODE_EFFORT_LEVEL=high // after: remove the line, or gate it per model // CLAUDE_CODE_EFFORT_LEVEL=high # only when model supports effort, e.g. opus-plan
Defensive patterns
Strategy: validation
Validate before calling
// Check before starting the SDK subprocess
import { readFileSync, existsSync } from 'fs';
const envPath = `${process.env.HOME}/.claude-mem/.env`;
if (existsSync(envPath) && readFileSync(envPath, 'utf8').includes('CLAUDE_CODE_EFFORT_LEVEL')) {
console.warn('CLAUDE_CODE_EFFORT_LEVEL will leak into SDK env; remove it for models without effort support');
} Try / catch
try {
await query({ ... });
} catch (err) {
if (/effort parameter/i.test(String(err.message))) {
delete process.env.CLAUDE_CODE_EFFORT_LEVEL; // scrub and retry
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/f93a87056075683e.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker/ClaudeProvider.ts:139
// the pattern in GeminiProvider.classifyGeminiError / classifyOpenRouterError
// (see #2357: the SDK forwards `effort` to the Messages API when
// CLAUDE_CODE_EFFORT_LEVEL leaks into the subprocess env, and models like
// Haiku/Sonnet 4.5 reject with 400 — without this branch the default
// `transient` classification retried indefinitely).
if (errAny.status === 400) {
// Inspect both the message and any structured body for the effort marker.
const bodyText = (() => {
const body = errAny.body;
if (typeof body === 'string') return body;
if (body && typeof body === 'object') {
try { return JSON.stringify(body); } catch { return ''; }
}
return '';
})();
const haystack = `${message}\n${bodyText}`;
if (/effort parameter/i.test(haystack) && !effortHintLogged) {
effortHintLogged = true;
logger.warn(
'SDK',
'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.',
{ status: 400 }
);
}
return new ClassifiedProviderError(
message || 'Anthropic bad request (status 400)',
{ kind: 'unrecoverable', cause: err },
);
}
// Status-less Anthropic 400s — SDK wrapping can drop `.status`, leaving only
// the message or an `invalid_request_error` body; classify those as
// unrecoverable so the worker stops retrying a permanent config error (#2656).
// The status guard keeps statused 4xx/5xx on their own branches.
if (View on GitHub (pinned to d8bc9755e7)