Skip to content

[Ubuntu 24.04][Agent&Skills] tool_search_code generates invalid JS and logs repeated errors during successful agent runs #4780

@PrachiShevate-nv

Description

@PrachiShevate-nv

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

  1. 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).
  2. From the host, connect into the sandbox:
    nemoclaw sbox-58 connect
  3. 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
  4. Observe the logs printed in the same terminal while the agent runs.
  5. 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.

Metadata

Metadata

Assignees

Labels

NV QABugs found by the NVIDIA QA Teamarea: sandboxOpenShell sandbox lifecycle, runtime, config, or recoveryarea: skillsSkills, agent behaviors, prompts, or skill packagingplatform: ubuntuAffects Ubuntu Linux environments

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions