Skip to content

[Bug] 点击「设为默认 Agent」写入已废弃字段 agents.entries.*.default,在 OpenClaw 2026.9.4 上必然报错 #342

Description

@ahbiaoge

问题描述

ClawPanel 的 Agent 管理页点击「设为默认 Agent」必定失败,弹出:

GatewayRequestError: invalid config: agents.ownership: agents.ownership=explicit
cannot be combined with a legacy default=true marker

环境

项目
OS Windows 11 (10.0.26200)
ClawPanel 0.21.6
OpenClaw 2026.9.4 (3a9d69d)
agents 2 个(agents.entries: dingtalk_xj / dingtalk_gx)
agents.ownership explicit

复现

  1. 配置 2 个 Agent,openclaw.jsonagents.ownership = "explicit"
  2. ClawPanel → Agent 管理 → 点击某 Agent 的「设为默认」
  3. 面板通过 WS 发 config.set,写入 agents.entries.<id>.default = true
  4. Gateway 返回 INVALID_REQUEST,配置无变化,功能失效

根因

1) schema 冲突openclaw/dist/zod-schema-*.mjs):

const marked = entries.filter(([, e]) => e.default === true);
if (value.ownership === "explicit" && marked.length > 0)
  ctx.addIssue({ path: ["ownership"], message:
    "agents.ownership=explicit cannot be combined with a legacy default=true marker" });

2) 该字段在 2026.9.4 已是「废弃(retired)」字段。 openclaw config validate 输出:

Config valid: ~\.openclaw\openclaw.json
2 warning(s):
  ! agents.entries: Materialized legacy per-surface agent ownership.
  ! agents.entries: Removed retired agents.entries.*.default markers.

即加载时迁移会清除 default 标记,把信息物化到 agents.ownership + systemAgent.agentId / sessionStore.agentId
所以该字段即使写入成功也存不住;若期间 ownership 也被移除,还会产生非法中间态并触发另一条错误:

multi-agent rosters require agents.ownership="explicit" or one legacy default=true marker

(本机历史上连续踩到这两条错误,排查成本很高。)

建议修复

「设为默认」应写入受支持的现代字段(其一或同时):

  • agents.defaults.systemAgent.agentId = "<id>"
  • agents.defaults.sessionStore.agentId = "<id>"

并在 agents.ownership === "explicit"不要agents.entries.<id>.default

依据(openclaw/dist/agent-scope-config-*.mjs):

function tryResolveAmbientOwnerAgentId(cfg, requestedAgentId) {
  const explicitAgentId = normalizeOptionalString(requestedAgentId)
    ?? normalizeOptionalString(cfg.agents?.defaults?.systemAgent?.agentId);
  return explicitAgentId ? normalizeAgentId(explicitAgentId)
                         : tryResolveLegacyCompatibilityAgentId(cfg);
}
function tryResolveRawLegacyDefaultAgentId(cfg) {
  if (cfg.agents?.ownership === "explicit") return;   // legacy 标记被忽略
  const marked = listAgentEntries(cfg).filter((e) => e.default === true);
  return marked.length === 1 ? normalizeAgentId(marked[0].id) : void 0;
}

证据

Gateway 日志(%TEMP%\openclaw\openclaw-2026-09-12.log):

[2026-09-12T08:26:03.769Z] gateway/ws :: res x config.set 109ms errorCode=INVALID_REQUEST
  errorMessage=invalid config: agents.ownership: agents.ownership=explicit cannot be
  combined with a legacy default=true marker   conn=b30c644f... id=69:1f72b93b-...
[2026-09-12T08:26:03.979Z] gateway/ws :: res x config.set 95ms  (同一错误,重试)

CLI 最小复现:

$ openclaw config set agents.entries.dingtalk_gx.default true
Config validation failed: agents.ownership: agents.ownership=explicit cannot be combined
with a legacy default=true marker

临时规避(修复前)

openclaw config set agents.defaults.systemAgent.agentId <agent-id>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions