Mintplex-Labs/anything-llm · error

agent not running

Error message

agent not running

What it means

Returned (HTTP 500) by POST /api/v1/help-response in the interface-service when the requestId matches the current workspace.pendingHelp, but both workspace.pendingHelp.rpc and workspace.piRpc are null. The response cannot be delivered because the RPC stream that would carry the extension_ui_response JSON message to the agent process is gone. The service nulls workspace.piRpc when the agent session ends or the process dies (api.js:380), but pendingHelp can survive that reset, so a matched id still 500s.

Source

Thrown at open-computer/services/interface-service/routes/api.js:438

        }
        console.log(`[pi] ${isLoop ? "Loop" : "Idle"} response: ${response || "(dismissed)"}`);
        return res.json({ status: "ok" });
      }

      const responseRpc = workspace.pendingHelp.rpc || workspace.piRpc;
      if (responseRpc) {
        responseRpc.write(
          JSON.stringify({
            type: "extension_ui_response",
            id: requestId,
            value: response || "",
          }) + "\n",
        );
        workspace.pendingHelp = null;
        console.log(`[pi] Help response sent: ${response}`);
        return res.json({ status: "ok" });
      }
      return res.status(500).json({ error: "agent not running" });
    }

    return res.status(404).json({ error: "no pending help request with that id" });
  });

  // ── Headless root ──────────────────────────────────────────────────────

  app.get("/", (req, res, next) => {
    if (!HEADLESS) return next();
    res.json({
      service: "interface-service",
      agent: AGENT_NAME,
      status: "ok",
      agent_status: currentAgentStatus(),
      headless: true,
      uptime_seconds: Math.floor(process.uptime()),
      platform: process.platform,
      arch: process.arch,

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Restart or reconnect the agent (or POST /api/v1/session/new) so workspace.piRpc is re-established, then re-send the help response
  2. Check the agent status via GET / (headless root exposes agent_status) or the service logs to learn why the process died
  3. If the pending question is stale, start a new session and prompt the agent again instead of replaying the old requestId
  4. Service authors: also clear workspace.pendingHelp wherever piRpc drops to null, so stale dialogs return the 404 instead of a 500

Example fix

// before
const res = await fetch(`${BASE}/api/v1/help-response`, {
  method: 'POST', headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({requestId, response}),
});

// after: verify the agent is alive, and restart before retrying
const status = await (await fetch(`${BASE}/`)).json();
if (status.agent_status !== 'running')
  await fetch(`${BASE}/api/v1/session/new`, {method: 'POST'});
const res = await fetch(`${BASE}/api/v1/help-response`, {
  method: 'POST', headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({requestId, response}),
});
if (res.status === 500) {
  const {error} = await res.json();
  if (error === 'agent not running') { /* re-ask the agent; this dialog is undeliverable */ }
}
Defensive patterns

Strategy: retry

Validate before calling

const status = await (await fetch(`${BASE}/`)).json(); // headless root returns agent_status
if (status.agent_status !== 'running') {
  await fetch(`${BASE}/api/v1/session/new`, {method: 'POST'}); // re-establish workspace.piRpc
}

Try / catch

try {
  const res = await fetch(`${BASE}/api/v1/help-response`, opts);
  if (!res.ok) {
    const body = await res.json().catch(() => ({}));
    if (res.status === 500 && body.error === 'agent not running') {
      await restartAgentSession(); // then let the agent re-ask; do not loop on the stale id
    }
  }
} catch (e) {
  // network-level failure reaching the interface-service itself
}

Prevention

When it happens

Trigger: POST /api/v1/help-response with body {requestId, response} where requestId === workspace.pendingHelp.id, the id does NOT start with 'idle-' or 'loop-' (those take the nudge branch), and the pi agent process has crashed, exited, or was restarted via POST /api/v1/session/new so that workspace.piRpc is null and pendingHelp.rpc is unset.

Common situations: Agent OOM-killed or container restarted between asking for help and the user answering; a new session started (clears piRpc at api.js:380) while the help dialog was still open in the UI; headless deployment where the pi child process died silently; extension RPC disconnected before the user clicked submit.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/2f494982de6895f6. Report an issue: GitHub.