#How do i create a second agent to work in the same openclaw interface?

1 messages · Page 1 of 1 (latest)

proper oar
#

I want a second agent (or a sub agent) to work along side my current agent. How can i achieve this?

glossy shadowBOT
#

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

calm windBOT
rare spruceBOT
#

You’ve got two different patterns here:

1. A second full agent (persistent, isolated)

Use this if you want another “brain” with its own workspace, sessions, and auth.

openclaw agents add work
openclaw agents list --bindings

That creates a separate agent with its own:

  • workspace
  • session history
  • auth profiles

Important: auth is per-agent, so the new one may need its own login/config, or you copy its auth-profiles.json into the new agent dir. Do not reuse the same agentDir.

#

Docs:

2. A sub-agent (helper working alongside current agent)

Use this if you want your current agent to delegate work in parallel.

  • One-shot helper: /subagents spawn <agentId> <task>
  • Programmatic: sessions_spawn
  • Long-lived Discord thread helper: spawn with thread: true and mode: "session"

If you want persistent Discord thread-bound subagents, enable thread bindings:

{
#

Quick rule of thumb

  • Want a separate persona / separate memory / separate auth → add another agent
  • Want a worker helping the current conversation → use a sub-agent

If you want, paste your openclaw --version plus whether you mean Dashboard, Discord, or CLI, and I can give you the exact setup for your case.

proper oar
#

Can a sub agent just be considered a child of the main agent? Does this run under the same api key? Because i want / need it to be able to run independently from the main agent, kind of like a worker under a manager. My main agent is the manager. I want to have 5-10 workers with their own tasks, and i talk to the manager who talks to those agents. Should those be sub agents or more tangible seperate brains?

rare spruceBOT
#

Yes, a sub-agent is basically a child run/session of the parent.

But for your case, there’s an important distinction:

Sub-agent

Good for: worker jobs, delegation, parallel execution

  • Runs as a child session
  • Usually inherits the parent’s agent identity unless you target another agentId
  • If you spawn it under the same agent, it uses the same auth store / API keys
  • If you target a different agentId, it loads that agent’s auth, but the main agent’s auth is still available as fallback
  • So: not fully hard-isolated auth

Docs explicitly say fully isolated per-agent auth is not supported yet.

Separate agent

Good for: real “worker brains”

#
  • Own workspace
  • Own session history
  • Own prompt/persona
  • Own agentDir/auth store
  • More like a durable specialist than a temporary child job

My recommendation for your setup

For a manager + 5 to 10 workers pattern, I’d use a hybrid:

  • Make the workers real separate agents
  • Let the manager spawn/delegate to them as sub-agent runs

That gives you:

  • persistent worker identities
  • separate memory/workspaces
  • manager-worker orchestration
#

So basically:

  • plain subagents only = ephemeral workers
  • separate agents only = separate brains, but not automatically orchestrated
  • best fit for you = separate worker agents + manager delegates to them

A couple config notes

If you want 5 to 10 workers in parallel, watch these defaults:

  • maxChildrenPerAgent: default 5
  • maxConcurrent: default 8
  • maxSpawnDepth: default 1

If the main agent is the manager, depth 1 is usually fine, because it can spawn workers directly.
If you want a sub-agent orchestrator that itself spawns more workers, then set maxSpawnDepth >= 2.

proper oar
#

Hi Krill! I'm trying to create a new independent agent in OpenClaw. I want the agent to be named AI-News-Analyst with the ID ai-news-analyst.

Could you give me the exact CLI commands to:
Create this new agent profile.
Set its default model to google/gemini-3.1-flash-lite-preview.
Configure its heartbeat interval to 480 minutes.

I want this to be a separate agent (Peer) with its own configuration, not a sub-agent spawn. Thanks!"

rare spruceBOT
#

Yep, for a separate peer agent (not a sub-agent), these are the verified commands:

# 1) Create the new agent with its own workspace and default model
openclaw agents add ai-news-analyst \
  --workspace ~/.openclaw/workspace-ai-news-analyst \
  --model google/gemini-3.1-flash-lite-preview \
  --non-interactive

# 2) Set the friendly display name
openclaw agents set-identity \
  --agent ai-news-analyst \
  --name "AI-News-Analyst"

# 3) Find this agent's index in agents.list[]
IDX="$(openclaw config get agents.list --json | python3 -c 'import sys,json; agents=json.load(sys.stdin); print(next(i for i,a in enumerate(agents) if a.get(\"id\")==\"ai-news-analyst\"))')"
#

# 4) Set this agent's heartbeat interval to 480 minutes
openclaw config set "agents.list[$IDX].heartbeat.every" "480m"

Optional checks:

openclaw agents list
openclaw config get "agents.list[$IDX]"
openclaw status

Two important gotchas:

  1. Auth is per-agent.
#

If this new agent needs its own Gemini auth/profile, you still need to configure that for ai-news-analyst or copy its auth-profiles.json into the new agent’s agent dir.

  1. Per-agent heartbeat behavior:
    Once you set agents.list[$IDX].heartbeat, OpenClaw treats heartbeat as per-agent. Docs say that when any agent defines heartbeat, only those agents run heartbeats.

Docs:

Glad that helped! 🎉
If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution.
This helps Answer Overflow index the solution for future users.

proper oar
# rare spruce Yep, for a **separate peer agent** (not a sub-agent), these are the verified com...

(base) vince@Intelicons-Mac-mini ~ % IDX="$(openclaw config get agents.list --json | python3 -c 'import sys,json; agents=json.load(sys.stdin); print(next(i for i,a in enumerate(agents) if a.get("id")=="ai-news-analyst"))')"
File "<string>", line 1
import sys,json; agents=json.load(sys.stdin); print(next(i for i,a in enumerate(agents) if a.get("id")=="ai-news-analyst"))
^
SyntaxError: unexpected character after line continuation character

#

@rare spruce

rare spruceBOT
#

I’m here 🦐 Did the corrected command work, or are you still getting an error?

proper oar
# rare spruce I’m here 🦐 Did the corrected command work, or are you still getting an error?

(base) vince@Intelicons-Mac-mini ~ % IDX="$(openclaw config get agents.list --json | python3 -c 'import sys,json; agents=json.load(sys.stdin); print(next(i for i,a in enumerate(agents) if a.get("id")=="ai-news-analyst"))')"
File "<string>", line 1
import sys,json; agents=json.load(sys.stdin); print(next(i for i,a in enumerate(agents) if a.get("id")=="ai-news-analyst"))
^
SyntaxError: unexpected character after line continuation character

rare spruceBOT
#

Ah, something is still mangling the inline Python in your shell. Let’s skip that entirely.

If you only have main plus this new agent, ai-news-analyst is almost certainly index 1, so just run:

openclaw config set agents.list[1].heartbeat.every "480m"
openclaw config get agents.list[1]

If you already have more agents and want to confirm the index first:

openclaw config get agents.list --json

Then look for the entry with:

#
"id": "ai-news-analyst"

and use that zero-based index in:

openclaw config set agents.list[<INDEX>].heartbeat.every "480m"

So for example, if it’s the third agent in the list, that would be:

openclaw config set agents.list[2].heartbeat.every "480m"

If you want, paste the output of:

#
openclaw config get agents.list --json

and I’ll tell you the exact index.

proper oar
#

(base) vince@Intelicons-Mac-mini ~ % openclaw config set agents.list[1].heartbeat.every "480m"
openclaw config get agents.list[1]
zsh: no matches found: agents.list[1].heartbeat.every
zsh: no matches found: agents.list[1]
(base) vince@Intelicons-Mac-mini ~ % openclaw config get agents.list --json
[
{
"id": "main"
},
{
"id": "ai-news-analyst",
"name": "ai-news-analyst",
"workspace": "/Users/vince/.openclaw/workspace-ai-news-analyst",
"agentDir": "/Users/vince/.openclaw/agents/ai-news-analyst/agent",
"model": "google/gemma-4-31b-it",
"identity": {
"name": "AI-News-Analyst"
}
}
]

It seems its indexed not by number but by ID? wanna try that?

rare spruceBOT
#

Yep, the issue is zsh globbing, not OpenClaw indexing.

[1] is being treated by zsh as a pattern unless you quote it.

Use:

openclaw config set 'agents.list[1].heartbeat.every' '480m'
openclaw config get 'agents.list[1]' --json

So, still indexed by number, not by ID. You just need quotes around paths containing brackets in zsh.

Also, I notice your agent currently has: