#23721: feat(inbound-meta): expose account_id in inbound_meta.v1 schema
channel: whatsapp-web
size: XS
Cluster:
Signal Plugin Enhancements
## Problem
Multi-account setups (e.g. WhatsApp personal + business numbers) need the agent to know which account received the message. The `AccountId` field was already available in `TemplateContext` but not surfaced in the `inbound_meta.v1` system prompt.
Without `account_id`, agents in multi-account setups cannot:
- Distinguish which account/phone received the message
- Apply per-account behavior (e.g. active mode vs bodyguard mode)
- Prevent echo loops when the same workspace handles multiple accounts
## Use Case
A user runs two WhatsApp accounts: personal (passive/bodyguard) and business (active). Both are bound to agents sharing the same workspace. The agent needs to know which account received the message to apply the correct persona. Without `account_id` in trusted metadata, the agent has no reliable way to distinguish the source.
## Solution
Add `account_id` to the trusted `inbound_meta.v1` JSON payload in the system prompt.
```ts
// In src/auto-reply/reply/inbound-meta.ts
const payload = {
schema: 'openclaw.inbound_meta.v1',
chat_id: safeTrim(ctx.OriginatingTo),
channel: channelValue,
account_id: safeTrim(ctx.AccountId), // ← NEW
// ...
};
```
This is a **session-stable field** (doesn't change per-turn), so it won't affect prompt caching.
## How to Verify
1. Configure two WhatsApp accounts (`eko` and `eqm`)
2. Send a message to each account
3. Check the system prompt — `account_id` should show the correct account name
4. Agent can now branch behavior based on `account_id`
## Files Changed
- `src/auto-reply/reply/inbound-meta.ts` — add `account_id` to payload (1 line)
- `src/auto-reply/reply/inbound-meta.test.ts` — add test for `account_id` presence
1 field added, 1 test added. All 14 existing tests continue to pass.
## Related
- PR #23685 — fix `selfChatMode` config usage (related multi-account work)
- Issue #23788 — selfChatMode regression bug
Most Similar PRs
#15407: feat: Add `message_id` to inbound metadata
by frosso · 2026-02-13
65.0%
#20801: fix: auto-select enabled account when only one is available
by mariusorani · 2026-02-19
64.5%
#20948: fix: propagate accountId from heartbeat delivery context to agent run
by odrobnik · 2026-02-19
63.0%
#8507: fix: preserve accountId for multi-account agent-to-agent messaging
by djh58 · 2026-02-04
63.0%
#14852: feat(matrix): add multi-account support
by tfm-neo-ai · 2026-02-12
62.8%
#23685: fix(whatsapp): restore selfChatMode config usage in access control
by ekson73 · 2026-02-22
62.5%
#23333: fix(matrix): add accountId routing for multi-account message sending 🤖
by BadTurki · 2026-02-22
62.3%
#16259: fix(cron): pass accountId through delivery path for multi-account c...
by ComputClaw · 2026-02-14
61.7%
#8879: fix(sessions-spawn): resolve target agent's bound accountId for sub...
by gianni-dalerta · 2026-02-04
61.5%
#8095: fix(sessions): include accountId in deliveryContext for outbound pe...
by codeslayer44 · 2026-02-03
61.5%