Skip to content

code-mode: AgentToolsSchema rejects "codeMode" key but docs say agent-level config works #83388

@Kaspre

Description

@Kaspre

Scope: Bug directly in the Openclaw Code Mode implementation introduced by #80600 (the per-agent schema path was missed when codeMode was added at the top-level ToolsSchema). Surfaced while testing #80600 on 2026.5.16-beta.4.

Problem

docs/reference/code-mode.md (line 67) says:

Add tools.codeMode.enabled: true to the agent or runtime config

But the per-agent tools zod schema (AgentToolsSchema) is .strict() and doesn't include codeMode. Only the top-level ToolsSchema accepts it. Per-agent enablement isn't possible — the gateway rejects the config.

Change and value

Either add codeMode: CodeModeSchema.optional() to AgentToolsSchema, or correct the doc to say "runtime/top-level only".

Per-agent enablement is the more useful option — it allows testing code mode on a single agent without forcing fleet-wide behavior change during evaluation or gradual rollout.

Who's affected

Anyone reading the documented agent-level config and trying to apply it. Affects evaluation/testing workflows where mixing code-mode and non-code-mode agents in the same fleet is desirable.

Reproduction

Tested on Openclaw 2026.5.16-beta.4.

  1. Add to openclaw.json:
    {
      "agents": {
        "list": [
          {
            "id": "test-agent",
            "tools": { "codeMode": { "enabled": true } }
          }
        ]
      }
    }
  2. openclaw gateway restart

Expected

Gateway starts; code mode enabled for test-agent only.

Actual

Gateway rejects config validation:

agents.list.0.tools: Unrecognized key: "codeMode"
Run "openclaw doctor --fix" to repair, then retry.

Schema evidence

In dist/zod-schema.agent-runtime-CMJF3lIB.js:

  • Line 471: const AgentToolsSchema = z.object({ ...CommonToolPolicyFields, elevated, exec, fs, loopDetection, message, sandbox }).strict()no codeMode
  • Line 662: const ToolsSchema = z.object({ ...CommonToolPolicyFields, ..., codeMode: CodeModeSchema, ... }) — codeMode present at top-level only

Suggested fix

Add codeMode: CodeModeSchema.optional() to AgentToolsSchema so the documented agent-level enablement works. If a per-agent override isn't intended, instead remove "agent or" from the docs.

Local workaround

Set tools.codeMode.enabled: true at the root of openclaw.json. This enables code mode for every agent in the fleet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions