tinyhumansai/openhuman · error · Error
RPC token not provided and ${tokenPath} could not be read. P
Error message
RPC token not provided and ${tokenPath} could not be read. Pass --token or set OPENHUMAN_CORE_TOKEN. What it means
Token resolution failure in readToken() of harness-subagent-rpc-audit. The bearer for the /rpc endpoint comes from --token (or OPENHUMAN_CORE_TOKEN) first; otherwise the script reads <workspace>/core.token — the file a standalone core writes next to its RPC server. If neither source yields a token, the audit refuses to make any call.
Source
Thrown at scripts/debug/harness-subagent-rpc-audit.mjs:198
"utf8",
);
const match = active.match(/^\s*user_id\s*=\s*"([^"]+)"\s*$/m);
if (match?.[1]) {
return path.join(openhumanDir, "users", match[1], "workspace");
}
} catch {
// Fall through to legacy root workspace.
}
return openhumanDir;
}
async function readToken(opts) {
if (opts.token.trim()) return opts.token.trim();
const tokenPath = path.join(opts.workspace, "core.token");
try {
return (await readFile(tokenPath, "utf8")).trim();
} catch {
throw new Error(
`RPC token not provided and ${tokenPath} could not be read. Pass --token or set OPENHUMAN_CORE_TOKEN.`,
);
}
}
async function rpc(coreUrl, token, method, params, timeoutMs = 600_000) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), timeoutMs);
let res;
try {
res = await fetch(coreUrl, {
method: "POST",
signal: controller.signal,
headers: {
"content-type": "application/json",
authorization: `Bearer ${token}`,
},
body: JSON.stringify({View on GitHub (pinned to a221052e0d)
Solutions
- Pass the token explicitly: `--token $(cat <real-workspace>/core.token)` or export OPENHUMAN_CORE_TOKEN
- Point --workspace at the workspace the target core actually serves (check where core.token exists)
- Or switch to `--spawn-core` so the harness generates and injects the token itself
- If the core is not running, start it first (`./target/debug/openhuman-core serve`) so core.token appears
Example fix
# before node scripts/debug/harness-subagent-rpc-audit.mjs --workspace ~/.openhuman # after export OPENHUMAN_CORE_TOKEN="$(cat ~/.openhuman/users/<id>/workspace/core.token)" node scripts/debug/harness-subagent-rpc-audit.mjs --workspace ~/.openhuman/users/<id>/workspace
Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync, existsSync } from "node:fs";
const ws = process.env.OPENHUMAN_WORKSPACE ?? "~/.openhuman";
const tokenPath = `${ws}/core.token`;
const token = process.env.OPENHUMAN_CORE_TOKEN ?? (existsSync(tokenPath) ? readFileSync(tokenPath, "utf8").trim() : "");
if (!token) { console.error(`no token: set OPENHUMAN_CORE_TOKEN or ensure ${tokenPath} exists`); process.exit(2); } Prevention
- Prefer --spawn-core so token generation is the script's job
- When attaching, resolve --workspace to the directory that actually contains core.token
When it happens
Trigger: Attaching to a core without --spawn-core while (a) no --token and no OPENHUMAN_CORE_TOKEN env, and (b) the resolved --workspace (or OPENHUMAN_WORKSPACE) does not contain core.token — wrong workspace path, a core that runs embedded in the desktop app (which hands the token in-memory, not via that file), or a core not yet started so the file was never written.
Common situations: Default workspace resolution picked ~/.openhuman root instead of the per-user workspace that actually holds core.token; running against the desktop app's embedded core; the core was started in another terminal and its workspace differs from the one passed here.
Related errors
- RPC token not provided and ${tokenPath} could not be read. P
- RPC token not found at ${tokenPath}. Pass --token or set OPE
- RPC token not provided and ${tokenPath} could not be read. P
- Core RPC token unavailable in Tauri; local RPC auth cannot b
- Core RPC HTTP ${response.status}: ${text || response.statusT
AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16).
Data as JSON: /api/errors/1650f4c48f09efd5.
Report an issue: GitHub.