Description
Inside a NemoClaw OpenShell sandbox on Ubuntu 24.04, running openclaw agent with NemoClaw to perform a simple file-creation task causes the embedded tool_search_code helper to generate invalid JavaScript for the tool runtime. This results in multiple [tools] tool_search_code failed errors (require is not defined, bad openclaw.tools.describe and openclaw.tools.search calls) being logged during an agent run that ultimately succeeds and creates the file. This both indicates a mismatch between the code generator and the runtime, and makes successful runs appear error-filled.
Environment
Device: Ubuntu 24.04 server
OS: Ubuntu 24.04
Architecture: x86_64
Node.js: v22.22.3
npm: 10.9.8
Docker: Docker version 29.2.1, build a5c7197
OpenShell CLI: openshell 0.0.44
NemoClaw: nemoclaw v0.0.58
OpenClaw: OpenClaw 2026.5.22 (a374c3a)
Steps to Reproduce
- Install NemoClaw and OpenShell on Ubuntu 24.04, with a healthy gateway and sandbox
sbox-58 (dashboard reachable on port 18791, openclaw status inside sandbox reports gateway reachable).
- From the host, connect into the sandbox:
- Inside the sandbox, run an agent request that should use tools to create a file:
openclaw agent -m "Create a file called /tmp/s04-test.txt with the content HELLO" --session-id s04-test
- Observe the logs printed in the same terminal while the agent runs.
- After the agent completes, check the file:
ls -l /tmp/s04-test.txt
cat /tmp/s04-test.txt
Expected Result
tool_search_code should generate JavaScript that is valid for the actual runtime and tool API:
- No use of CommonJS
require if the JS engine does not support it.
openclaw.tools.describe(id) called with valid string ids.
openclaw.tools.search(query) called with the correct parameter type.
Successful agent runs should not emit multiple [tools] tool_search_code failed error messages in normal logs; at most, a minimal internal probe should occur without noisy failures.
For the test prompt, /tmp/s04-test.txt should be created with content HELLO, and logs should reflect a clean tool selection and execution.
Actual Result
The agent request starts normally and NemoClaw is registered:
OpenClaw 2026.5.22 (a374c3a) ...
18:47:49 [plugins] ┌────────────────────────────────────────────────────────┐
18:47:49 [plugins] │ NemoClaw registered │
18:47:49 [plugins] │ │
18:47:49 [plugins] │ Endpoint: Managed Inference Route (inference.local) │
18:47:49 [plugins] │ Provider: NVIDIA Endpoints │
18:47:49 [plugins] │ Model: nvidia/nemotron-3-super-120b-a12b │
18:47:49 [plugins] │ Slash: /nemoclaw │
18:47:49 [plugins] └────────────────────────────────────────────────────────┘
During the run, tool_search_code repeatedly logs failures for invalid JS snippets:
18:58:19 [agent/embedded] tool-search: cataloged 28 tools behind compact prompt surface
[tools] tool_search_code failed: ReferenceError: require is not defined
raw_params={"code":"const fs = require('fs');\ntry {\n fs.writeFileSync('/tmp/s04-test.txt', 'HELLO');\n return { success: true, message: 'File written' };\n} catch (e) {\n return { success: false, error: e.message };\n}"}
[tools] tool_search_code failed: Error: describe id must be a string.
raw_params={"code":"return await openclaw.tools.describe();"}
[tools] tool_search_code failed: Error: Unknown tool id: *
raw_params={"code":"return await openclaw.tools.describe(\"*\");"}
[tools] tool_search_code failed: Error: Unknown tool id: tools.list
raw_params={"code":"return await openclaw.tools.call(\"tools.list\", {});"}
[tools] tool_search_code failed: Error: search query must be a string.
raw_params={"code":"return await openclaw.tools.search({ query: \"write\" });"}
[tools] tool_search_code failed: Error: search query must be a string.
raw_params={"code":"return await openclaw.tools.search({ query: \"list\" });"}
[tools] tool_search_code failed: Error: search query must be a string.
raw_params={"code":"return await openclaw.tools.search({ query: \"file\" });"}
[tools] tool_search_code failed: Error: Unknown tool id: search
raw_params={"code":"return await openclaw.tools.describe(\"search\");"}
- The runtime reports
ReferenceError: require is not defined for CommonJS-style code in a non-CommonJS environment.
openclaw.tools.describe() is called with missing or invalid ids (undefined, "*", "search"), causing "describe id must be a string" or "Unknown tool id" errors.
openclaw.tools.search() is invoked with { query: "..." } instead of the expected string, yielding "search query must be a string" errors.
Despite these repeated errors, the agent eventually prints a success message:
File created successfully at /tmp/s04-test.txt with content "HELLO". Verified by reading the file back.
Verifying in the sandbox shows the file exists and contains the correct content, so the user-visible task succeeds even though the logs look error-heavy.
Logs
The excerpt above is the core evidence; it shows both the invalid JS code generated by tool_search_code and the fact that the run ultimately claims success:
[tools] tool_search_code failed: ReferenceError: require is not defined
...
[tools] tool_search_code failed: Error: describe id must be a string.
...
[tools] tool_search_code failed: Error: Unknown tool id: *
...
[tools] tool_search_code failed: Error: Unknown tool id: tools.list
...
[tools] tool_search_code failed: Error: search query must be a string.
...
[tools] tool_search_code failed: Error: Unknown tool id: search
...
File created successfully at /tmp/s04-test.txt with content "HELLO". Verified by reading the file back.
Description
Inside a NemoClaw OpenShell sandbox on Ubuntu 24.04, running
openclaw agentwith NemoClaw to perform a simple file-creation task causes the embeddedtool_search_codehelper to generate invalid JavaScript for the tool runtime. This results in multiple[tools] tool_search_code failederrors (require is not defined, badopenclaw.tools.describeandopenclaw.tools.searchcalls) being logged during an agent run that ultimately succeeds and creates the file. This both indicates a mismatch between the code generator and the runtime, and makes successful runs appear error-filled.Environment
Steps to Reproduce
sbox-58(dashboard reachable on port 18791,openclaw statusinside sandbox reports gateway reachable).openclaw agent -m "Create a file called /tmp/s04-test.txt with the content HELLO" --session-id s04-testExpected Result
tool_search_codeshould generate JavaScript that is valid for the actual runtime and tool API:requireif the JS engine does not support it.openclaw.tools.describe(id)called with valid string ids.openclaw.tools.search(query)called with the correct parameter type.Successful agent runs should not emit multiple
[tools] tool_search_code failederror messages in normal logs; at most, a minimal internal probe should occur without noisy failures.For the test prompt,
/tmp/s04-test.txtshould be created with contentHELLO, and logs should reflect a clean tool selection and execution.Actual Result
The agent request starts normally and NemoClaw is registered:
During the run,
tool_search_coderepeatedly logs failures for invalid JS snippets:ReferenceError: require is not definedfor CommonJS-style code in a non-CommonJS environment.openclaw.tools.describe()is called with missing or invalid ids (undefined,"*","search"), causing "describe id must be a string" or "Unknown tool id" errors.openclaw.tools.search()is invoked with{ query: "..." }instead of the expected string, yielding "search query must be a string" errors.Despite these repeated errors, the agent eventually prints a success message:
Verifying in the sandbox shows the file exists and contains the correct content, so the user-visible task succeeds even though the logs look error-heavy.
Logs
The excerpt above is the core evidence; it shows both the invalid JS code generated by
tool_search_codeand the fact that the run ultimately claims success: