NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

[CLI] `sessions reset` always fails: OPENCLAW_GATEWAY_TOKEN is never provided to the in-sandbox script that needs it

Open mill101 opened this issue 4 months ago • 1 comments

Investigation Summary

Hello,

  • nemoclaw <sandbox> sessions reset <key> fails 100% of the time with "OPENCLAW_GATEWAY_TOKEN ... required for NemoClaw sessions admin RPCs", thrown from inside the sandbox at /sandbox/[eval1]:49.
  • Per its own --help, the command works by "invoking the OpenClaw gateway sessions.reset RPC from inside the sandbox" -- but nothing populates OPENCLAW_GATEWAY_TOKEN in that in-sandbox context.
  • The token is not missing from the system: nemoclaw <sandbox> gateway-token prints a valid 64-character token on demand. The CLI can obtain it; it just never passes it to the script it evaluates inside the sandbox.
  • Setting OPENCLAW_GATEWAY_TOKEN in the host environment before invoking the CLI does not help -- it is not forwarded into the sandbox.
  • sessions list works normally, so the read path is fine; only the admin RPCs appear affected. I did not test sessions delete (destructive), but the error text says "sessions admin RPCs" in the plural, so it likely shares the code path.

Description

nemoclaw <sandbox> sessions reset <key> cannot succeed in its current form. It evaluates a script inside the sandbox that requires OPENCLAW_GATEWAY_TOKEN, but nothing ever sets that variable in the sandbox environment, so the script throws before doing any work.

What happened

$ nemoclaw my-hermes sessions reset 20260726_031708_c61148ad
✓ Active gateway set to 'nemoclaw-8990'
  Failed to reach the OpenClaw gateway in sandbox 'my-hermes': exit 1
  file:///sandbox/[eval1]:49
  if (!token) throw new Error("OPENCLAW_GATEWAY_TOKEN ... required for NemoClaw sessions admin RPCs");
                    ^

  Error: OPENCLAW_GATEWAY_TOKEN ... required for NemoClaw sessions admin RPCs
      at file:///sandbox/[eval1]:49:19
      at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
  Node.js v24.16.0
    Verify the gateway is reachable: `nemoclaw my-hermes status`.

What I expected

The session to be archived and its key rebound to a fresh sessionId, as --help describes.

Why this looks like a wiring gap rather than a user misconfiguration

  1. --help states the mechanism explicitly: "Archive the named session and rebind its key to a fresh sessionId by invoking the OpenClaw gateway sessions.reset RPC from inside the sandbox." The in-sandbox script is where the token is required.
  2. The token is readily available to the CLI -- nemoclaw <sandbox> gateway-token prints a valid 64-character token. So this is not a missing credential; it is a credential that is never handed to the code that asks for it.
  3. There is no documented flag or environment variable for supplying it. sessions reset --help lists only --agent, --reason, --json, --verbose.
  4. Exporting OPENCLAW_GATEWAY_TOKEN on the host before running the command has no effect, because the sandbox exec environment does not inherit it. Verified: the token was captured from gateway-token and exported, and the identical error still occurred.
  5. The failure happens before key handling. Line 49 is a if (!token) throw guard, so the command never reaches the point of resolving the session key -- meaning this is not a "bad key" problem. (I passed an ID taken from sessions list; whether that ID is also the accepted <key> form is untested, because the token guard fires first.)

Scope

nemoclaw <sandbox> sessions list works normally, so the read path is unaffected. Only the admin RPCs look broken. I did not run sessions delete because it is destructive, but the guard's wording ("sessions admin RPCs") suggests a shared path.

Impact

There is no supported way to reset a conversation session from the CLI. The practical workaround is to start a new conversation in the messaging channel (a new Slack thread gets a new session), but that leaves the stale session in place and is not usable for scripted or non-interactive cleanup.

Suggested fix

Have the CLI resolve the gateway token the same way gateway-token does and inject it into the in-sandbox script's environment. Failing that, accept it via a documented flag or a forwarded host environment variable, and say so in --help and in the error message -- the current message names the variable but gives the user no supported way to set it.

Reproduction Steps

  1. Have a sandbox with at least one conversation session:

    nemoclaw <sandbox> sessions list

    -> lists sessions with IDs, e.g. 20260726_031708_c61148ad (this works fine)

  2. Attempt to reset one:

    nemoclaw <sandbox> sessions reset 20260726_031708_c61148ad

    -> fails with "OPENCLAW_GATEWAY_TOKEN ... required for NemoClaw sessions admin RPCs" thrown from file:///sandbox/[eval1]:49

  3. Confirm a valid token exists and is obtainable:

    nemoclaw <sandbox> gateway-token

    -> prints a 64-character token plus a "treat this like a password" warning

  4. Try supplying it via the host environment:

    OPENCLAW_GATEWAY_TOKEN="$(nemoclaw <sandbox> gateway-token | head -1)" \ nemoclaw <sandbox> sessions reset 20260726_031708_c61148ad

    -> identical failure; the variable is not forwarded into the sandbox

Environment

  • OS: Windows 11 Pro 26200 + WSL2 (Ubuntu 24.04.4 LTS, kernel 6.6.114.1-microsoft-standard-WSL2)
  • Hardware: x86_64 workstation, NVIDIA GeForce RTX 5080
  • Node.js: v22.23.1 (host) / v24.16.0 (sandbox)
  • Docker: Docker Engine 29.4.0
  • NemoClaw: v0.0.90 (source HEAD acfa2613c7a645ae1bff21914f25d824e5fbcf62)
  • OpenShell: 0.0.85 (docker)
  • Hermes Agent: v0.18.0
  • Sandbox phase: Ready (doctor reports the gateway connected)

Debug Output

Excerpt from nemoclaw debug --quick, trimmed to the relevant sections (the full output contains unrelated provider/channel configuration for this deployment). Happy to attach the full bundle if useful.

═══ OpenShell ═══

Server Status Gateway: nemoclaw-8990 Server: https://127.0.0.1:8990 Status: Connected Version: 0.0.85

NAME CREATED PHASE my-hermes 2026-07-22 13:14:11 Ready

Sandbox: Id: 41784e5a-7387-486c-ad24-c5d2ae8240d5 Name: my-hermes Phase: Ready Policy source: sandbox

═══ Sandbox Internals ═══

UID PID PPID C STIME TTY TIME CMD root 1 0 0 Jul25 ? 00:00:34 /opt/openshell/bin/openshell-sandbox sandbox 79 1 1 Jul25 ? 00:09:30 bash /usr/local/bin/nemoclaw-start sandbox 246652 79 0 Jul25 ? 00:02:12 /opt/hermes/.venv/bin/python /usr/local/bin/hermes.real gateway run

The gateway is healthy and reachable -- sessions list against the same sandbox succeeds moments before and after the failing sessions reset.

Logs

$ nemoclaw my-hermes sessions reset 20260726_031708_c61148ad
✓ Active gateway set to 'nemoclaw-8990'
  Failed to reach the OpenClaw gateway in sandbox 'my-hermes': exit 1
  file:///sandbox/[eval1]:49
if (!token) throw new Error("OPENCLAW_GATEWAY_TOKEN <REDACTED> required for NemoClaw sessions admin RPCs");
                  ^

Error: OPENCLAW_GATEWAY_TOKEN <REDACTED> required for NemoClaw sessions admin RPCs
    at file:///sandbox/[eval1]:49:19
    at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
    at async node:internal/modules/esm/loader:230:26
    at async ModuleLoader.executeModuleJob (node:internal/modules/esm/loader:227:20)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Node.js v24.16.0
  Verify the gateway is reachable: `nemoclaw my-hermes status`.

(The "<REDACTED>" above is NemoClaw's own output sanitizer, not an edit by me.)

For contrast, the read path against the same sandbox works:

$ nemoclaw my-hermes sessions list
Title                Preview                          Last Active   ID
──────────────────────────────────────────────────────────

Checklist

  • [x] I confirmed this bug is reproducible
  • [x] I searched existing issues and this is not a duplicate

mill101 avatar Jul 26 '26 11:07 mill101

Hi, Thanks for picking this up. Having looked at #7588, I think my framing of this report was partly wrong, and I want to correct it — then raise one thing the PR may be leaving on the table.

Correction: my premise was off I reported this as "the token is not forwarded", assuming sessions reset was meant to work here. #7588 makes clear it is an OpenClaw-agent operation, and my sandbox runs Hermes Agent v0.18.0 (Harness: Hermes Agent (gateway)). The evidence was in front of me and I read past it — sessions reset --help does say "Reset an OpenClaw conversation session", and nemoclaw agents list fails on this sandbox with openclaw: not found.

So refusing early with a clear message, as #7588 does, is a real improvement over the current cryptic token error. No argument there.

What led me to the wrong conclusion (and may lead others there) sessions list works fine on this Hermes sandbox, and its --help says it is deliberately agent-aware:

Pass-through to the sandbox agent's sessions list ... command inside the sandbox via openshell sandbox exec — openclaw sessions ... for OpenClaw sandboxes, hermes sessions list ... for Hermes sandboxes; the in-sandbox binary is picked from the sandbox's agent.

Given that one sessions subcommand explicitly dispatches per agent and works, it is a natural (if wrong) inference that its siblings do too. That is the gap I fell into.

The part I think is worth reconsidering: delete #7588 refuses both sessions reset and sessions delete on non-OpenClaw agents. For reset that seems right — I could not find a Hermes equivalent. But delete does exist on the Hermes side:

$ nemoclaw exec -- hermes sessions --help usage: hermes sessions [-h] {list,export,delete,prune,optimize,repair,stats,rename,browse} ... $ nemoclaw exec -- hermes sessions delete --help usage: hermes sessions delete [-h] [--yes] session_id positional arguments: session_id Session ID to delete options: --yes, -y Skip confirmation So for sessions delete, the same pass-through pattern sessions list already uses would work, rather than refusing. hermes sessions additionally has prune and rename, if broader parity is ever of interest.

Suggestions sessions delete: dispatch to hermes sessions delete <session_id> on Hermes sandboxes, mirroring what sessions list already does, instead of refusing. sessions reset: refusing is fine. It would help if the refusal named the supported alternative — for Hermes, starting a new conversation thread in the messaging channel creates a fresh session, which is what I ended up doing. --help for reset/delete: state the agent requirement as plainly as sessions list --help states its dispatch behavior. Right now "OpenClaw" appears in the prose description but reads as product naming rather than a hard constraint. Happy to test a build if useful — this sandbox reproduces the original error reliably.

mill101 avatar Jul 26 '26 13:07 mill101