Two OpenClaw bindings cover one WhatsApp group: a channel-wide rule listed first, a rule for that group listed second — which agent answers, and why?
answer
- specificity before config order
- peer tiers sit at the top
- account beats channel wildcard
- order breaks ties within a tier
- AND across match fields
basics
~20 sThe agent bound to that group answers, provided that binding covers the message's account. OpenClaw ranks bindings by specificity tier, with exact peer matches above account and channel-wide matches; config order only breaks ties inside one tier.
solid answer
~40 sThe group's agent wins. OpenClaw routing is deterministic and most-specific-wins: it tries tiers in order (exact peer, parent peer for threads, peer wildcard, Discord guild plus roles, guild, Slack team, a specific account, the channel-wide `accountId: "*"`) and only then a fallback owner. A `match.peer` with `kind: "group"` and the group id sits in the first tier, the channel-wide rule in the eighth, so listing order between them is irrelevant. Order matters only when two bindings land in the same tier: the first in config wins. One catch: a peer binding that omits `accountId` applies only to the default account, so on another account it never enters the race.
go deeper
Remember that the most specific binding wins, and that a binding for one conversation beats a channel-wide one.
Walk the tier order from exact peer down to the channel wildcard, and explain that config order only breaks ties within one tier.
Trace a misroute: check account filtering before tiers, AND semantics across match fields, duplicate peers in one tier, and AGENT_SELECTION_REQUIRED for unbound traffic.
Set a convention for bindings files, narrow rules first, explicit account scope and a deliberate channel-wide fallback, so routing stays predictable as accounts are added.
## How OpenClaw picks one agent For every admitted inbound message, the Gateway resolves exactly one agent. The model plays no part; routing is deterministic and driven by the `bindings` array in `openclaw.json`. The rule the docs give is **most specific wins**, implemented as a fixed sequence of tiers. The first tier that has a matching binding decides. ## The tier order 1. **Exact peer**: `match.peer` with `kind` and a concrete `id` (one DM, group or channel). 2. **Parent peer**: thread inheritance, where a thread's parent conversation is bound. 3. **Peer wildcard**: `peer.id: "*"` for a peer kind. 4. **Guild plus roles** (Discord): `guildId` with `roles`. 5. **Guild** (Discord): `guildId` alone. 6. **Team** (Slack): `teamId`. 7. **Account**: a specific `accountId`, including an omitted one, which means the default account. 8. **Channel**: `accountId: "*"`, any account on that channel. 9. **Fallback owner**: a caller-supplied owner, the sole configured agent, or a retained legacy default. | Binding in the scenario | Tier | Wins? | |---|---|---| | `{ channel: "whatsapp", accountId: "*" }`, listed first | 8, channel | no | | `{ channel: "whatsapp", accountId: "*", peer: { kind: "group", id: "<group id>" } }`, listed second | 1, exact peer | yes | So the group goes to the agent named in the peer binding, even though it appears later in the file. ## Where config order does matter Inside a single tier, the first matching binding in config order wins. Two peer bindings for the same group, or two account bindings for the same account, are resolved by position. The docs therefore advise keeping narrow rules above broad ones, which also makes the file easier to read even when tiers already settle it. ## Two rules that change which tier applies - **AND semantics.** When one binding sets several match fields, such as `peer` plus `guildId`, all of them must match. A binding with a wrong guild id never matches, however specific its peer is. - **Account filtering comes first.** Before the tiers run, the Gateway keeps only bindings for this channel whose `accountId` equals the message's account or is `"*"`. A peer binding that omits `accountId` belongs to the default account only. If the group arrives on an account named `family`, that peer binding is filtered out and the channel-wide rule wins after all. Writing `accountId: "*"` or the real account id on the peer binding fixes it. ## Reading a bindings file the way the router does 1. Keep only bindings whose `match.channel` is the message's channel. 2. Of those, keep only bindings whose `accountId` is the message's account, or `"*"`; an omitted `accountId` counts as `default`. 3. Walk the tiers from exact peer down to channel and stop at the first tier with a binding whose every match field fits. 4. Inside that tier, take the first such binding in config order. 5. If no tier produced one, go to the fallback owner. Doing this by hand on a misroute usually finds the cause within the first two steps. ## When nothing matches If no tier matches, routing uses a fallback owner. In 2026.9.9 a multi-agent roster with `agents.ownership: "explicit"` does not pick the first roster entry: without a resolvable owner, such as the only configured agent or a legacy `default: true` marker, routing reports `AGENT_SELECTION_REQUIRED` and suggests adding a channel-wide binding. Single-agent installs are unaffected. ## Verifying what will happen - `openclaw agents list --bindings` prints each agent with its full routing rules, so you can read the effective set. - `openclaw agents bindings --agent <id>` lists one agent's bindings. - `openclaw logs --follow`, filtered for routing lines, shows decisions as messages arrive; with debug logging, the routing log names the tier that matched. ## Common misreadings - **"First match in the file wins."** Only within a tier. - **"A peer rule always wins."** Only on the accounts it is scoped to; an omitted `accountId` limits it to the default account. - **"Unmatched traffic goes to the first agent."** Not in an explicit multi-agent roster in 2026.9.9; it needs a binding or an owner. - **"A binding makes the group allowed."** Group policy and allowlists admit the message; the binding only picks the agent.
- The group binding omits `accountId`, and the group arrives on WhatsApp account `family`. Which rule wins now?The channel-wide `accountId: "*"` rule. Before tiers are compared, OpenClaw keeps only bindings whose accountId equals the message's account or is `"*"`; an omitted accountId means the default account, so the peer binding is filtered out. Give the peer binding `accountId: "family"` or `"*"`.
- Two OpenClaw bindings name the same WhatsApp group but different agents. Which answers?Both are exact-peer matches in the same tier, so the one that appears first in the `bindings` array wins. The second never fires for that group. Remove the duplicate, or route the group to several agents on purpose with broadcast groups, which is a separate feature.
- OpenClaw always uses the first binding in the file that matches.
- A peer binding without accountId applies on every account of the channel.
- When nothing matches, OpenClaw sends the message to the first agent listed.
- The model reads the message and chooses the best-suited agent.
- A binding with peer and guildId matches if either field matches.
Assumes OpenClaw 2026.9.9; the tier order is long-standing, but explicit multi-agent rosters no longer fall back to the first agent and report AGENT_SELECTION_REQUIRED instead.