Skip to content

Commit e75ca8e

Browse files
committed
test(code-mode): cover exec tool guidance
1 parent 196c77c commit e75ca8e

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Docs: https://docs.openclaw.ai
66

77
### Changes
88

9-
- Agents/code mode: sharpen the `exec` tool description so models do not waste turns rediscovering that Node modules are unavailable, that `language` rejects values other than `"javascript"`/`"typescript"`, and that the `tools.search`/`describe`/`call` bridge is the path for shell, file, network, and other I/O. Thanks @Kaspre.
109
- Agents/config: allow `agents.list[].experimental.localModelLean` so lean local-model mode can be enabled for one configured agent instead of globally.
1110
- Providers/xAI: add device-code OAuth login so remote and headless setups can authorize xAI without a localhost browser callback. (#84005) Thanks @fuller-stack-dev.
1211

src/agents/code-mode.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,29 @@ describe("Code Mode", () => {
245245
expect(language).not.toHaveProperty("oneOf");
246246
});
247247

248+
it("describes code-mode runtime constraints in the model-visible exec schema", () => {
249+
const { tools } = createCodeModeHarness();
250+
const execTool = tools[0];
251+
const parameters = execTool.parameters as {
252+
properties?: Record<string, Record<string, unknown>>;
253+
};
254+
255+
expect(execTool.description).toContain("Node.js modules");
256+
expect(execTool.description).toContain("`require`/`import` are NOT available");
257+
expect(execTool.description).toContain("`tools.search(query)`");
258+
expect(execTool.description).toContain("enabled catalog tools allowed by policy");
259+
expect(execTool.description).toContain("`tools.describe(entry.id)`");
260+
expect(execTool.description).toContain("`tools.call(entry.id, args)`");
261+
expect(execTool.description).toContain('"javascript" or "typescript"');
262+
263+
expect(parameters.properties?.code?.description).toContain("`tools` object");
264+
expect(parameters.properties?.code?.description).toContain("`ALL_TOOLS`");
265+
expect(parameters.properties?.code?.description).toContain("Node built-in modules are not");
266+
expect(parameters.properties?.language?.description).toContain(
267+
'Must be "javascript" or "typescript"',
268+
);
269+
});
270+
248271
it("removes legacy Tool Search controls from the visible code mode surface", () => {
249272
const { config, catalogRef, tools: codeModeTools } = createCodeModeHarness();
250273
const compacted = applyCodeModeCatalog({

src/agents/code-mode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ export function createCodeModeTools(ctx: CodeModeToolContext): AnyAgentTool[] {
826826
name: CODE_MODE_EXEC_TOOL_NAME,
827827
label: "exec",
828828
description:
829-
"Run JavaScript or TypeScript in OpenClaw code mode. Node.js modules and `require`/`import` are NOT available — for any shell, file, network, or external action, use the catalog bridge from inside your code: `tools.search(query)` to find tools, `tools.describe(name)` for the input schema, then `tools.call(name, args)`. The `language` field accepts only \"javascript\" or \"typescript\"; do not pass \"bash\", \"shell\", or other values.",
829+
"Run JavaScript or TypeScript in OpenClaw code mode. Node.js modules and `require`/`import` are NOT available — for any shell, file, network, or external action, use enabled catalog tools allowed by policy from inside your code: `tools.search(query)` to find catalog entries, `tools.describe(entry.id)` for the input schema, then `tools.call(entry.id, args)`. The `language` field accepts only \"javascript\" or \"typescript\"; do not pass \"bash\", \"shell\", or other values.",
830830
parameters: Type.Object({
831831
code: Type.String({
832832
description:

0 commit comments

Comments
 (0)