paperclipai/paperclip · error

Anthropic Managed Agents request failed with HTTP ${response

Error message

Anthropic Managed Agents request failed with HTTP ${response.status}

What it means

`anthropicRequest` throws this whenever the Anthropic Managed Agents API (api.anthropic.com, beta managed-agents-2026-04-01) responds with a non-OK HTTP status. The response body is discarded, so the message carries only the numeric status — 401/403 mean auth problems, 404 a bad resource id, 429 rate limiting, 5xx an Anthropic-side issue. It is raised for every GET/POST the command makes (environments, agents, sessions).

Source

Thrown at cli/src/commands/managed-agent.ts:133

async function anthropicRequest(
  key: string,
  method: "GET" | "POST",
  path: string,
  body?: Record<string, unknown>,
): Promise<Record<string, unknown>> {
  const response = await fetch(`${ANTHROPIC_ORIGIN}${path}`, {
    method,
    headers: {
      "x-api-key": key,
      "anthropic-version": ANTHROPIC_VERSION,
      "anthropic-beta": CLAUDE_MANAGED_BETA_VERSION,
      ...(body ? { "content-type": "application/json" } : {}),
    },
    ...(body ? { body: JSON.stringify(body) } : {}),
    signal: AbortSignal.timeout(15_000),
  });
  if (!response.ok) {
    throw new Error(`Anthropic Managed Agents request failed with HTTP ${response.status}`);
  }
  if (response.status === 204) return {};
  return record(await response.json());
}

async function listAll(key: string, path: string): Promise<RemoteResource[]> {
  const rows: RemoteResource[] = [];
  let page: string | null = null;
  do {
    const suffix = page ? `${path.includes("?") ? "&" : "?"}page=${encodeURIComponent(page)}` : "";
    const response = await anthropicRequest(key, "GET", `${path}${suffix}`);
    for (const value of Array.isArray(response.data) ? response.data : []) {
      rows.push(record(value) as RemoteResource);
    }
    page = typeof response.next_page === "string" && response.next_page
      ? response.next_page
      : null;
  } while (page);

View on GitHub (pinned to 5716fe907e)

Solutions

  1. Check the status in the message: 401/403 → re-export a valid ANTHROPIC_API_KEY; 404 → verify the resource id; 429 → back off and retry later; 5xx → retry after checking Anthropic status
  2. Confirm the beta header/version is current for your CLI release — beta endpoints change
  3. Re-run a single command manually to see if it is transient
  4. Capture the response body with curl against the same endpoint for the detailed error JSON the CLI discards

Example fix

// before
try { await runManagedAgentSetup(opts); } catch { /* silent */ }
// after
try {
  await runManagedAgentSetup(opts);
} catch (err) {
  if (/HTTP 429/.test(String(err))) {
    await sleep(60_000); // back off on rate limit, then retry once
    await runManagedAgentSetup(opts);
  } else {
    throw err;
  }
}
Defensive patterns

Strategy: retry

Validate before calling

// Preflight: verify credentials and resources before running the command
curl -s -o /dev/null -w "%{http_code}" -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" -H "anthropic-beta: managed-agents-2026-04-01" \
  https://api.anthropic.com/v1/environments

Try / catch

try {
  await setupManagedAgent(opts);
} catch (err) {
  const m = /HTTP (\d{3})/.exec(String(err));
  const status = m ? Number(m[1]) : 0;
  if (status === 429 || status >= 500) {
    await backoffRetry(() => setupManagedAgent(opts), { attempts: 3 });
  } else if (status === 401 || status === 403) {
    throw new Error("Anthropic key invalid/forbidden — re-export ANTHROPIC_API_KEY");
  } else throw err;
}

Prevention

When it happens

Trigger: Expired or revoked ANTHROPIC_API_KEY (401/403); wrong environmentId/agentId (404); exceeding Managed Agents beta rate limits (429); Anthropic outage or beta endpoint changes (500/503); a request taking over the 15-second AbortSignal timeout surfaces as a fetch abort rather than this error, but gateway 504s do hit it.

Common situations: Rotating the Anthropic key without updating the shell env; deleting an environment/agent in the Anthropic console while the CLI still references its id; running many setup commands in a loop and tripping rate limits; beta header/version drift after an API change.

Related errors


AI-assisted analysis of paperclipai/paperclip@5716fe907e (2026-09-02). Data as JSON: /api/errors/2e194ed7e937a300. Report an issue: GitHub.