rohitg00/agentmemory · error · Error

${init?.method || "GET"} ${path} -> ${res.status} ${res.stat

Error message

${init?.method || "GET"} ${path} -> ${res.status} ${res.statusText}

What it means

The MCP REST proxy resolves a handle by making an HTTP request to the agentmemory daemon. Any non-ok HTTP response (4xx/5xx) is converted into a thrown Error containing the method, path, HTTP status code, and status text. This is the standard failure mode when the daemon is unreachable, auth fails, or the endpoint returns an error.

Source

Thrown at src/mcp/rest-proxy.ts:150

        `[@agentmemory/mcp] AGENTMEMORY_FORCE_PROXY set; skipping livez probe and trusting ${url}\n`,
      );
    }
    if (up) {
      const handle: ProxyHandle = {
        mode: "proxy",
        baseUrl: url,
        call: async (path, init) => {
          const res = await fetch(`${url}${path}`, {
            ...init,
            headers: {
              "content-type": "application/json",
              ...authHeader(),
              ...(init?.headers as Record<string, string> | undefined),
            },
            signal: AbortSignal.timeout(CALL_TIMEOUT_MS),
          });
          if (!res.ok) {
            throw new Error(
              `${init?.method || "GET"} ${path} -> ${res.status} ${res.statusText}`,
            );
          }
          const text = await res.text();
          return text ? JSON.parse(text) : null;
        },
      };
      cached = handle;
      cachedAt = Date.now();
      return handle;
    }
    const local: LocalHandle = { mode: "local" };
    cached = local;
    cachedAt = Date.now();
    return local;
  })();
  try {
    return await probeInFlight;

View on GitHub (pinned to e04ba88819)

Solutions

  1. Read the HTTP status in the message: 401/403 -> fix the auth secret/token; 404 -> check AGENTMEMORY_URL and that the daemon version exposes the endpoint; 5xx -> check daemon logs.
  2. Verify the daemon is running: curl AGENTMEMORY_URL/agentmemory/health.
  3. Correct AGENTMEMORY_URL to point at the right host/port (default port 49134's REST surface).
  4. Retry the call if the status is 5xx and the daemon was momentarily restarting.

Example fix

// before
const res = await handle("memory_search", { query }); // throws POST /agentmemory/search -> 401 Unauthorized
// after
try {
  const res = await handle("memory_search", { query });
} catch (e) {
  if (/-> 40[13]/.test(e.message)) fixAuth();
  else if (/-> 5\d\d/.test(e.message)) await retry(handle, ["memory_search", { query }]);
  else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

async function daemonHealthy(url) {
  try {
    const r = await fetch(`${url}/agentmemory/health`, { signal: AbortSignal.timeout(2000) });
    return r.ok;
  } catch { return false; }
}

Try / catch

const m = /^(\w+) (\S+) -> (\d{3}) (.*)$/.exec(err.message);
if (m) {
  const [, method, path, status, statusText] = m;
  if (status === "401" || status === "403") await refreshToken();
  else if (status.startsWith("5")) await retryWithBackoff();
  else throw err; // 4xx: caller bug, don't retry
}

Prevention

When it happens

Trigger: Calling any proxied tool while the daemon responds with e.g. 401 Unauthorized (bad secret), 404 (endpoint not registered / wrong AGENTMEMORY_URL path), 500 (handler threw), or 502/503 (daemon behind a proxy that cannot reach it).

Common situations: Daemon not running or listening on a different port, AGENTMEMORY_URL misconfigured, stale/missing auth token in authHeader(), a version mismatch where the client calls an endpoint the daemon doesn't expose.

Related errors


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/3e48124dfba30173. Report an issue: GitHub.