#Subagent creation problems

1 messages · Page 1 of 1 (latest)

thorny garden
#

I am having extreme issues creating subagents. I tried all models from Haiku, Sonnet, Opus, GLM4.7 and the bot just fails this simple task. It continuously overwrites by main agent with the "new" agent I want to create. It cannot figure that the agent list, must contain the main agent as well as the new one. I finally managed to fix it by adding the main manually, but any changes I ask it to do to the new agent config, it removed the main one from the list.

Is this a known issue? It shouldn't be that complicated. Do the models have no access to the openclaw docs?

hollow inletBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

idle ruinBOT
#

What you’re seeing is a pretty common failure mode, and it’s usually not “subagents are broken” so much as “the config got replaced”.

Why it keeps deleting your main agent

If the bot (or you via the UI/API) is using config.apply, that call replaces the entire config. So if the model outputs a partial object like:

{ agents: { list: [ { id: "new-agent", ... } ] } }

…then your previous agents.list (including { id: "main" }) is gone. The FAQ calls this out explicitly: config.apply must include the full config, otherwise everything else is removed.
Docs: https://docs.openclaw.ai/help/faq (see “config.apply wiped my config”)

Also: arrays like agents.list are inherently “replace-y” in most patch/merge workflows, so models tend to mess this up unless they’re forced to preserve existing entries.

The reliable way to add/edit an extra agent (without nuking main)

Use the CLI to edit only the new agent entry:

#
  • Inspect:

    openclaw config get agents.list
    
  • Set fields on the 2nd agent without touching the 1st:

    openclaw config set agents.list[1].model "anthropic/claude-opus-4-6"
    openclaw config set agents.list[1].name "My Subagent"
    

    (Add --json when you’re setting non-strings / objects.)

CLI docs: https://docs.openclaw.ai/cli/config

What the config is supposed to look like

From the config reference, your agents.list should include both agents, e.g.:

#
agents: {
  list: [
    { id: "main", default: true, subagents: { allowAgents: ["*"] } },
    { id: "my-sub", name: "My Subagent", model: "..." },
  ],
}

Config ref (agents.list + subagents.allowAgents):
https://docs.openclaw.ai/gateway/configuration-reference

“Do the models have access to the docs?”

Not automatically. They only “know” what’s in their prompt/context unless they’re explicitly instructed (and have tools enabled) to read local docs files. Even then, models are often bad at safely editing config structures like arrays unless you constrain the workflow.

Quick questions so we can pinpoint your exact path

  1. What does openclaw --version print?
#
  1. Are you changing config via the dashboard “apply”, via chat (agent calling config.apply), or by editing the JSON5 file / using openclaw config set?
  2. Can you paste your current agents.list (redact tokens/keys)?
thorny garden
#
  1. it was 2026.2.13
  2. it seems the agent is calling config.apply, not config.patch. at the end I added the agent manually with openclaw agents add coder (i found it surprising that the coder had agent files that matched this description, without any prompting)
  3. the formatting is crap (because of ssh)
    217 │ "list": [
    218 │ {
    219 │ "id": "main"
    220 │ },
    221 │ {
    222 │ "id": "coder",
    223 │ "workspace": "/Users/telemachos/.openclaw/workspace-coder",
    224 │ "model": {
    225 │ "primary": "zai/glm-4.7",
    226 │ "fallbacks": [
    227 │ "anthropic/claude-sonnet-4-5"
    228 │ ]
    229 │ },
    230 │ "skills": [
    231 │ "coding-agent"
    232 │ ],
    233 │ "heartbeat": {
    234 │ "every": "0"
    235 │ },
    236 │ "sandbox": {
    237 │ "mode": "non-main",
    238 │ "workspaceAccess": "rw",
    239 │ "sessionToolsVisibility": "spawned",
    240 │ "scope": "session",
    241 │ "docker": {
    242 │ "image": "node:20-alpine",
    243 │ "readOnlyRoot": true,
    244 │ "tmpfs": [
    245 │ "/tmp",
    246 │ "/var/tmp"
    247 │ ],
    248 │ "network": "none",
    249 │ "capDrop": [
    250 │ "ALL"
    251 │ ],
    252 │ "memory": "2048m",
    253 │ "cpus": 2
    254 │ }
    255 │ }
    256 │ }
    257 │ ]
idle ruinBOT
#

What you’re seeing lines up with expected semantics of the config RPCs, plus the model making a bad choice:

So this isn’t really “subagent creation is broken” as much as: “editing agents.list via LLM tool calls is a footgun unless the model always fetches the current config and re-sends the full array.”

Practical workaround (recommended)

Use the CLI for agent lifecycle, and config set for tweaks:

  • Add agent safely:
    openclaw agents add coder
    
#

Docs: https://docs.openclaw.ai/cli/agents

  • Then tweak fields without rewriting the whole agents.list array:
    openclaw config get agents.list
    # pick the right index for coder, then:
    openclaw config set agents.list[IDX].model.primary "zai/glm-4.7"
    openclaw config set agents.list[IDX].skills '["coding-agent"]' --json
    
    Docs: https://docs.openclaw.ai/cli/config

This avoids the “array replace” trap entirely.

“Do the models have access to the docs?”

Not automatically. Unless you explicitly give the agent docs (or it has tools/permissions to read them), the model is basically guessing. The docs do warn about config.apply and config.patch array behavior, but the model won’t reliably internalize that unless prompted/tool-assisted.

If you want this fixed “properly”

#

If you can reproduce it reliably, it’s worth a GitHub issue proposing safer primitives (e.g. an agents.add/agents.update RPC/tool that doesn’t require rewriting agents.list). Issue tracker: https://github.com/openclaw/openclaw/issues