rohitg00/agentmemory · warning

observe failed for ${obs.toolName}: ${res.status} ${res.stat

Error message

observe failed for ${obs.toolName}: ${res.status} ${res.statusText}${body ? ` — ${body.slice(0, 160)}` : ""}

What it means

The CLI's observe flow POSTs tool observations to the daemon's REST API; when the response status is not ok, it logs 'observe failed for <toolName>: <status> <statusText> — <body excerpt>' via p.log.warn. The daemon answered, but rejected or errored on the observation (e.g. 400 bad payload, 401 bad secret, 404 wrong route/version mismatch). Non-fatal: the session continues and only session/end uses strict POST.

Source

Thrown at src/cli.ts:2889

    };

    try {
      const res = await fetch(url, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(payload),
        signal: AbortSignal.timeout(5000),
      });
      if (res.ok) {
        stored++;
      } else {
        const body = await res.text().catch(() => "");
        p.log.warn(
          `observe failed for ${obs.toolName}: ${res.status} ${res.statusText}${body ? ` — ${body.slice(0, 160)}` : ""}`,
        );
      }
    } catch (err) {
      p.log.warn(
        `observe request failed for ${obs.toolName}: ${err instanceof Error ? err.message : String(err)}`,
      );
    }
  }

  await postJsonStrict(`${base}/agentmemory/session/end`, { sessionId: session.id });
  return stored;
}

async function runDemoSearch(base: string, query: string): Promise<SearchResult> {
  const data = await postJson<{ results?: Array<{ title?: string }> }>(
    `${base}/agentmemory/smart-search`,
    { query, limit: 5 },
    10000,
  );
  const items = data?.results ?? [];
  return {
    query,

View on GitHub (pinned to e04ba88819)

Solutions

  1. Read the status/body in the message: fix auth for 401 (align AGENTMEMORY_SECRET) or the payload for 400.
  2. Update the CLI to match the daemon version (npm update agentmemory) so the observe endpoint exists.
  3. Check the daemon is the real agentmemory server, not another service answering on that port (an HTML body hints at a proxy).
  4. Retry manually with curl -H "Authorization: Bearer $AGENTMEMORY_SECRET" to the observe endpoint to see the full error.

Example fix

// before: stale secret on CLI
// observe failed for Bash: 401 Unauthorized
// after
export AGENTMEMORY_SECRET=$(cat ~/.agentmemory/secret)
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`${base}/agentmemory/session/observe`, {
  method: "POST",
  headers: { Authorization: `Bearer ${secret}`, "Content-Type": "application/json" },
  body: JSON.stringify(obs),
});
if (!res.ok) console.warn(`pre-check failed: ${res.status} ${await res.text()}`);

Try / catch

try {
  const res = await postObservation(obs);
  if (!res.ok) {
    const body = await res.text().catch(() => "");
    console.warn(`observe failed: ${res.status} ${body.slice(0,160)}`);
    if (res.status === 401) fixSecret();
  }
} catch (err) { /* network error — observation dropped, non-fatal */ }

Prevention

When it happens

Trigger: A POST of a tool observation returns res.ok === false, typically 401 (wrong AGENTMEMORY_SECRET), 400 (payload fails REST field validation/whitelisting), or 404 (daemon version without the observe route).

Common situations: CLI and daemon version mismatch after an upgrade; mismatched AGENTMEMORY_SECRET between CLI and daemon; a proxy between them returning an error page body (which appears truncated in the message).

Related errors


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