#Openclaw group chat experiment

1 messages · Page 1 of 1 (latest)

candid gulch
#

How do I setup my two OpenClaw agents so they can talk together between them?

hardy nimbusBOT
crimson timberBOT
#

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

hardy nimbusBOT
barren boltBOT
#

By default, they don’t cross-talk. For two standalone agents to talk to each other, the important bits are:

{
  tools: {
    sessions: {
      visibility: "all", // needed so session tools can see other agents
    },
    agentToAgent: {
      enabled: true,
      allow: ["home", "work"], // your agent IDs
    },
  },

  session: {
    agentToAgent: {
#
      maxPingPongTurns: 5, // optional, lets them bounce replies back and forth
    },
  },
}

Also, if you use tool allowlists, make sure both agents can use at least:

  • sessions_list
  • sessions_history
  • sessions_send
  • session_status

Then restart:

#
openclaw gateway restart

After that, one agent can message the other with sessions_send, typically targeting the other agent’s main session, for example agent:work:main.

The gotcha is: tools.sessions.visibility: "all" and tools.agentToAgent.enabled: true are both required. Without those, cross-agent sends are blocked.

Docs:

If you want, I can paste a full minimal 2-agent config example for home + work.

candid gulch
#

Any discord specifics settings I have to change for the agent to agent thing?

barren boltBOT
#

Nope, not for the plain agent-to-agent part.

sessions_send / cross-agent messaging is an internal session tool thing, so the important settings are still the ones from before:

  • tools.sessions.visibility: "all"
  • tools.agentToAgent.enabled: true
  • tools.agentToAgent.allow: [...]

For Discord specifically, you only need the normal routing/setup pieces:

  1. Each bot you use needs normal Discord setup

    • invited to the server
    • Message Content Intent enabled
    • access to the channels you want
  2. If each agent should be a different Discord bot/account, bind each accountId to an agentId:

#
{
  bindings: [
    { agentId: "main",   match: { channel: "discord", accountId: "default" } },
    { agentId: "coding", match: { channel: "discord", accountId: "coding" } },
  ],
  channels: {
    discord: {
      accounts: {
        default: { token: "..." },
        coding:  { token: "..." },
      },
    },
  },
}
#
  1. If both agents share one Discord bot, that’s fine too. Then you just route them with normal bindings by channel / peer / guild, not a special Discord A2A switch.

The one Discord-specific extra is only if you want thread-bound spawned sessions (sessions_spawn({ thread: true })):

{
  channels: {
    discord: {
      threadBindings: {
        enabled: true,
        spawnSubagentSessions: true,
      },
    },
  },
}
narrow folio
#

Paste both examples please

barren boltBOT
#

Yep, here are both.

1) One Discord bot, two agents

Route by channel (or guild/peer), both agents share the same bot identity.

{
  agents: {
    list: [
      { id: "home", workspace: "~/.openclaw/workspace-home" },
      { id: "work", workspace: "~/.openclaw/workspace-work" },
    ],
  },

  bindings: [
    {
#
      agentId: "home",
      match: {
        channel: "discord",
        guildId: "123456789012345678",
        peer: { kind: "channel", id: "222222222222222222" }, // #home-bot
      },
    },
    {
      agentId: "work",
      match: {
        channel: "discord",
        guildId: "123456789012345678",
        peer: { kind: "channel", id: "333333333333333333" }, // #work-bot
      },
    },
#
  ],

  tools: {
    sessions: {
      visibility: "all",
    },
    agentToAgent: {
      enabled: true,
      allow: ["home", "work"],
    },
  },

  session: {
    agentToAgent: {
      maxPingPongTurns: 5, // optional
#
    },
  },

  channels: {
    discord: {
      enabled: true,
      token: {
        source: "env",
        provider: "default",
        id: "DISCORD_BOT_TOKEN",
      },
      groupPolicy: "allowlist",
      guilds: {
        "123456789012345678": {
          channels: {
#
            "222222222222222222": { allow: true, requireMention: false },
            "333333333333333333": { allow: true, requireMention: false },
          },
        },
      },
    },
  },
}

2) Two Discord bots, two agents

Route by accountId, each agent has its own Discord bot identity.

#
{
  agents: {
    list: [
      { id: "home", workspace: "~/.openclaw/workspace-home" },
      { id: "work", workspace: "~/.openclaw/workspace-work" },
    ],
  },

  bindings: [
    { agentId: "home", match: { channel: "discord", accountId: "homebot" } },
    { agentId: "work", match: { channel: "discord", accountId: "workbot" } },
  ],

  tools: {
    sessions: {
#
      visibility: "all",
    },
    agentToAgent: {
      enabled: true,
      allow: ["home", "work"],
    },
  },

  session: {
    agentToAgent: {
      maxPingPongTurns: 5, // optional
    },
  },

  channels: {
#
    discord: {
      groupPolicy: "allowlist",
      accounts: {
        homebot: {
          token: {
            source: "env",
            provider: "default",
            id: "DISCORD_BOT_TOKEN_HOME",
          },
          guilds: {
            "123456789012345678": {
              channels: {
                "222222222222222222": { allow: true, requireMention: false },
              },
            },
#
          },
        },
        workbot: {
          token: {
            source: "env",
            provider: "default",
            id: "DISCORD_BOT_TOKEN_WORK",
          },
          guilds: {
            "123456789012345678": {
              channels: {
                "333333333333333333": { allow: true, requireMention: false },
              },
            },
          },
#
        },
      },
    },
  },
}

Important footguns

  • If you use tool allowlists, both agents also need:
    • sessions_list
    • sessions_history
    • sessions_send
    • session_status
  • With two bots in the same channel and requireMention: false, both may answer every message.
  • For plain agent-to-agent talking, there is no extra Discord-only switch beyond normal bot setup/bindings.
candid gulch
#

Oh yes can you send the test prompt? It seems my agent is confused

barren boltBOT
#

Yep, use this super-literal one first.

Simple test prompt

Send this to the first agent:

Do exactly these steps:

1. Call `sessions_send`
2. Use `sessionKey: "agent:work:main"`
3. Use `message: "Reply with exactly: pong from work"`
4. Use `timeoutSeconds: 30`
5. After the tool returns, print the reply you got

Do not use the `message` tool.
Do not explain the plan first.
#

If your target agent is named something else, swap work for that agent ID.


If the agent is still confused, use this even more explicit version

Use the `sessions_send` tool now with:

- sessionKey: "agent:work:main"
- message: "Reply with exactly: pong from work"
- timeoutSeconds: 30

Then show me the result.

#

Diagnostic prompt

If that fails, send this to the first agent:

Please troubleshoot cross-agent messaging.

1. Use `sessions_list` and check whether `agent:work:main` is visible.
2. If visible, use `session_status` on `agent:work:main`.
3. Then try `sessions_send` to `agent:work:main` with message `Reply with exactly: pong from work` and timeoutSeconds 30.
4. Show me the exact error or reply.

Do not guess. Use the tools.

What the failure usually means

  • “not visible” → tools.sessions.visibility is wrong
  • “agent-to-agent disabled/denied” → tools.agentToAgent.enabled / allow is wrong